aboutsummaryrefslogtreecommitdiff
path: root/lib/memfs/internal
AgeCommit message (Collapse)Author
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2025-01-06lib/memfs: remove GoEmbed test that generate dynamic timesShulhan
The GoEmbed test that write Go embedded code into "internal/test/embed/" may create unnecessary changes when the test run on new clone of this repository, or when we run "go test" again on that package after rebasing.
2024-12-28lib/bytes: split the hexdump related functions to separate packageShulhan
Package hexdump implements reading and writing bytes from and into hexadecimal number. It support parsing output from hexdump(1) tool.
2024-09-04all: fix various linter warningsShulhan
While at it, temporary disable gosec due to excessive report for G115, which may be true, but may also break the current working program. We should alter and fix once we can test and make sure that it does not breaks.
2024-08-03lib/memfs: another fix for refreshShulhan
In previous commit we use wrong condition when handling directory "." as Root.
2024-07-22lib/memfs: sanitize the Root directory to fix refreshShulhan
In [MemFS.refresh], if the requested url is "/file1" and [Options.Root] is ".", the path during refresh become "file1" and if passed to [filepath.Dir] it will return ".". This cause the loop on refresh never end because there is no PathNodes equal with ".".
2024-04-10lib/memfs: set embed file mode to print as octalShulhan
Using octal in mode make the code more readable, for example mode with permission "0o644" much more readable than 420.
2024-03-09all: reformat all files with goimportsShulhan
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2023-11-22lib/memfs: add sub file systemShulhan
This implemented simplified version of merging multiple MemFS instances. The sub file system (subfs) can be added to the parent MemFS instance by calling new method "Merge". parent.Merge(other *MemfS) When Get method called, each subfs will be evaluated in order of Merge called. This deprecated the function Merge.
2023-11-14lib/memfs: improve the refresh methodShulhan
Instead of refreshing from the Root, find the directory that closes to the requested path. While at it, simplify the returned error.
2023-11-08lib/memfs: refactoring, simplify DirWatcher logicShulhan
In this changes, we simplify re-scanning the directory content. Instead of looping on node Childs to detect new or delete files, use map to store previous Childs first. If node path exist in map then add it again as child, otherwise delete it.
2023-11-05lib/memfs: include empty directoryShulhan
Even thought empty directory does not contains file, from the parent node _it is_ part of their content. Also, there is a use case where memfs use as virtual file system (VFS), as a layer with file system, where user can view list of directory, create a directory or file on the fly. If we skip scanning empty directory, that directory will not be visible.
2022-08-31lib/memfs: simplify checking for symlinkShulhan
Instead of calling filepath.EvalSymlink and Lstat, call os.Stat directly to the symlink system path. This also fix the modTime not currently set to the original file when creating Node from symlink-ed file.
2022-07-02lib/memfs: update the template formatShulhan
Replace ":=" with "var" and realign the field assignments.
2022-05-12lib/memfs: format comment in embedded Go template according to gofmt tipShulhan
In the next gofmt (Go v1.19), the comment format does not allow empty lines "//" at the top and bottom of the comment. This changes make the generated Go code from Embed method to match as close as possible with output of gofmt.
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2022-03-01lib/memfs: make the GoEmbed re-mount the Root before generate Go fileShulhan
Previously, we assume that the PathNodes from instance of MemFS is already up to date. If PathNodes is initialized by previous GoEmbed and the Root directory contains new files or directories, that new files does not get embedded. This changes fix this issue by force re-mount the whole Root directory before generating the Go file.
2022-02-14lib/memfs: add option CommentHeader to EmbedOptionsShulhan
The CommentHeader option allow user to define custom header to the Go generated file. The string value is not checked, whether it's a comment or not, it will rendered as is.
2021-12-20lib/memfs: fix unit testsShulhan
Previous commits, embed the GenFuncName into the generated Go embed file which forgot to update the unit tests.
2021-12-19lib/memfs: remove field ContentEncoding from EmbedOptions and NodeShulhan
The original idea for option ContentEncoding in EmbedOptions and Node is to save spaces, compressing the content on disk on embedding and doing transport, when the MemFS instance is used to serve the (embedded) contents of file system. This option turns out break the HTTP content negotiation [1] of accept-encoding header, if the HTTP server does not handle it properly, which default Go HTTP server does not. In order to prevent this issue in the future, for anyone who use the memfs for serving static HTTP contents, we remove the options and store the embedded content as is and let the HTTP server handle how the compression by itself. [1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
2021-10-26lib/memfs: move the go embed test to directory internal/testShulhan
This is to remove "embed_test" being displayed on the documentation page.
2021-10-26lib/memfs: move the embedded parameter to OptionsShulhan
Since the GoEmbed can be called only when MemFS instance is initiated, it would be better if parameters for GoEmbed also initialized in the struct Options. In this way any additional parameters needed to add to GoEmbed does not changes the method signature in the future. This commit add new type EmbedOptions that contains the parameters for GoEmbed. In this new type, we add new field EmbedWithoutModTime. if its true, the modification time for all files and directories are not stored inside generated code, instead all files will use the current time when the program is running.