Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemMapFs open windows absolute path does not exist #225

Open
nofun97 opened this issue Nov 10, 2019 · 5 comments · May be fixed by #226
Open

MemMapFs open windows absolute path does not exist #225

nofun97 opened this issue Nov 10, 2019 · 5 comments · May be fixed by #226

Comments

@nofun97
Copy link

nofun97 commented Nov 10, 2019

Doing fs.Open("c:\\") or afero.Walk from root on a MemMapFs in a windows system returns the error open c:\: file does not exist. During debugging, I found that the getData() function in MemMapFs does not support windows root as shown by the TODO in it (https://github.com/spf13/afero/blob/master/memmap.go#L38).

I would like to fix it in my fork, if it is okay.

@nofun97 nofun97 linked a pull request Nov 11, 2019 that will close this issue
@bep
Copy link
Collaborator

bep commented Jan 15, 2020

In my head, MemMapFs is another filesystem ... And I don't see how that could/should emulate different file systems.

fs.Open("c:\\") when the fs is a map does not make much sense to me, but maybe it does to others ...

@nofun97
Copy link
Author

nofun97 commented Jan 15, 2020

I agree, but MemMapFs is a great testing tool and I think it would be really beneficial for it to be able to emulate different file systems.

I encountered the problem during testing a program I am working on. Part of the code is to process absolute filepaths and it uses these filepaths to generate files. We wanted to test that the files were created in MemMapFs by walking from the system root. It works on Linux, but it could never work on Windows because c:\\ was never initialized and we have to start from c:\\ because the function filepath.Abs from the package path/filepaths would attach volume names in Windows.

I don't think the changes I made in #226 would change how MemMapFs works, it can still be another filesystem, it's just going to be more compatible with path/filepaths

@MMulthaupt
Copy link

There are uses for both, a generic memory-mapped file system, as well as a memory-mapped OS mock file system. We need file systems like MemMapFsWindows, MemMapFsLinux and a convenience method afero.NewMemMapFsOs() to get one according to runtime.GOOS. If I have Windows-specific functionality in my file system-savvy code, I can otherwise not test it with afero.

@MMulthaupt
Copy link

I believe what OP (and I) could use is something along the lines of afero.Abs(), with a working directory parameter if need be.

@nofun97 It has been three years; do you remember if or how you solved the problem?

@Monirzadeh
Copy link

afero.Abs()

@MMulthaupt do you mean IsAbs?
same things happen with fs.MkdirAll because of

afero/basepath.go

Lines 76 to 78 in 5c4385a

if filepath.IsAbs(name) {
return os.ErrNotExist
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants