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

Files can incorrectly be nested inside other files #1049

Open
NotWearingPants opened this issue Aug 2, 2024 · 3 comments · May be fixed by #1052
Open

Files can incorrectly be nested inside other files #1049

NotWearingPants opened this issue Aug 2, 2024 · 3 comments · May be fixed by #1052

Comments

@NotWearingPants
Copy link

NotWearingPants commented Aug 2, 2024

It's possible to read/write files nested inside other files:

const { fs } = require('memfs');
fs.writeFileSync('/foo', 'hello');
fs.writeFileSync('/foo/bar', 'world');
console.log(fs.readFileSync('/foo', 'utf8')); // logs 'hello'
console.log(fs.readFileSync('/foo/bar', 'utf8')); // logs 'world'
console.log(fs.statSync('/foo').isFile()); // logs 'true'
console.log(fs.statSync('/foo').isDirectory()); // logs 'false'
console.log(fs.readdirSync('/foo')); // throws ENOTDIR

/foo is a regular file, and bar is also a regular file that's nested in /foo.

Tested with v4.11.1

@G-Rath G-Rath changed the title File & Directory superposition Files can incorrectly be nested inside other files Aug 2, 2024
@G-Rath
Copy link
Collaborator

G-Rath commented Aug 2, 2024

Yup that's a bug alright

@Kenny4297
Copy link

Hi @NotWearingPants, I think I may be able to help with this issue. I would love to be assigned to it if possible!

@G-Rath
Copy link
Collaborator

G-Rath commented Aug 3, 2024

@Kenny4297 go for it!

Kenny4297 added a commit to Kenny4297/memfs that referenced this issue Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants