Giter Site home page Giter Site logo

Comments (3)

mrbean-bremen avatar mrbean-bremen commented on May 21, 2024

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.

jmcgeheeiv avatar jmcgeheeiv commented on May 21, 2024

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.

mrbean-bremen avatar mrbean-bremen commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.