Failing to get Stat for a Directory - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Failing to get Stat for a Directory (/thread-34324.html) Pages:
1
2
|
RE: Failing to get Stat for a Directory - bowlofred - Jul-20-2021 (Jul-20-2021, 09:40 PM)tester_V Wrote: Sorry for the confusion! That depends on the filesystem. You cannot take that as a rule. Try it on another filesystem (even on the same machine) and that expectation may be broken. Here's a directory on my machine (appears to be an xfs filesystem) with nothing but 3 empty files. But the "size" of the directory is not zero.
Quote:I'm not looking if a directory has file/files or not because if it has a file and filesize=0 it is an "Empty" directory. It is an empty file. To call it an empty directory is against common usage. An empty directory has no members and rmdir() will succeed on it. Your directory does not match that description.Quote:I'm looking if a directory size is =0. I thought I could do that with 'pathil.Path'. You can do that with Path, but the meaning of such directories depends on knowing the specific filesystem you are dealing with. As such it is not recommended. It will fail when you do not expect. Don't do it that way. I don't have access to a NTFS filesystem at the moment. Your code does exactly what I would expect on my filesystem.
RE: Failing to get Stat for a Directory - Larz60+ - Jul-20-2021 OK, now i understand what it is your trying to do. |