Comments (3)
I have been thinking about this in connection with the file system space and the newly introduced hard link support. I propose to introduce support for both st_ino and st_dev to cover this:
- add st_ino as proposed
- add a default st_dev (instead of None), set st_dev according to the parent directory on file/directory creation
- under Windows, instead of st_dev the result of splitdrive() shall be used (maybe st_dev can be used internally); not sure yet about automatic creation of a new file system if adding a file on a new drive
- add something like AddRoot() to FakeFilesystem to be able to add a new file system root with a new st_dev, with an optional total_space parameter to set the available space per file system
- adapt the space handling for newly created files accordingly, adapt disk_usage to account for the path parameter
- change shutil.move() to use os.rename() if on the same file system, otherwise copy2, as proposed in point 3 (will work with os.rename if PR #101 is merged)
- adapt os.rename() to throw if on different file systems (seems to be the default on most Unix systems, have to check under Windows)
- please add whatever I forgot
@jmcgeheeiv: If this is ok, I may have a go at this somewhere in the next weeks (after the open PRs are merged, to have a consistent start).
If you are going to make a new pypi release, as you proposed, I think it would be a good time before this is added.
from pyfakefs.
How ambitious and impressive.
We will need to make sure that AddRoot() is properly documented with an example.
In the meantime, I'll get on those other PRs and make a release.
from pyfakefs.
Ok, thanks. I won't comment on "ambitious and impressive" :p
I have a question regarding st_ino:
Both CreateFile() and CreateDirectory() have an optional inode argument. What is the use case for these? Will this still be needed, if we automatically give each file/directory a unique inode number? If we allow to set set an arbitrary number, this may clash with an existing number (which generally will just increase for each new object) and I'm not sure how to handle this. I see these possibilities:
- remove the argument and document it in the release notes
- make the argument deprecated and issue a warning if using it
- add a backwards compatibility option to support the argument instead of the automatic assignment
What do you think?
from pyfakefs.
Related Issues (20)
- TypeError: unhashable type HOT 1
- Creating pytz `timezone` always returns `UnknownTimeZoneError` HOT 2
- Tests failing with pyfakefs and django after first test HOT 8
- python 3.9.18 + pyfakefs + pathlib + class variable: test failed HOT 4
- sdist is missing `tox.ini` HOT 3
- pyfakefs 5.3.4 + moto 4.2.13, test failed HOT 1
- Example usage docs using pathlib leads to errors HOT 2
- pyarrow.lib.ArrowKeyError: A type extension with name pandas.period already defined HOT 9
- Infinite loop with multiprocessing HOT 4
- EncodingWarnings raised (3) when using pyfakefs HOT 7
- Adding/removing directory entries does not respect directory ownership HOT 1
- Directory enumeration/search permissions mismatch Unix behavior HOT 3
- Wrong temporary directory created following a reset via `fs.os` HOT 4
- The `io.open` function should not consider file permissions when opening from an existing file descriptor HOT 3
- Patched `os.symlink` mishandles directory descriptors HOT 3
- Missing mock of `os.dup` HOT 4
- `os.getxattr` should raise `OSError(ENODATA)` for non-existent extended attributes HOT 1
- Patched `os.open` does not respect `O_NOFOLLOW` HOT 1
- Faked `os.link` is missing the `follow_symlinks` parameter HOT 1
- Fake `os.open` does not handle the `O_DIRECTORY` flag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyfakefs.