[issue46791] Allow os.remove to defer to rmdir

2022-03-01 Thread Eryk Sun
Eryk Sun added the comment: glibc remove() has an optimization to skip calling rmdir() if the macro condition IS_NO_DIRECTORY_ERROR is true for the unlink() error. For Linux, this condition is `errno != EISDIR`. On other platforms (e.g. BSD systems), the condition is `errno != EPERM`. The im

[issue46791] Allow os.remove to defer to rmdir

2022-02-28 Thread Eryk Sun
Eryk Sun added the comment: > For REMOVE_BOTH, I don't see the need of calling GetFileAttributes I was thinking that the NtQueryAttributesFile() system call is relatively cheap compared to a full open, especially if the attributes of a remote file are cached locally. However, on second thoug

[issue46791] Allow os.remove to defer to rmdir

2022-02-28 Thread benrg
benrg added the comment: The REMOVE_DIR case reduces to return RemoveDirectoryW(path->wide) ? 0 : -1; so I think there's no reason to combine it with the other two. The REMOVE_BOTH case is attrs = GetFileAttributesW(path->wide); if (attrs != INVALID_FILE_ATTRIBUTES && (attrs &

[issue46791] Allow os.remove to defer to rmdir

2022-02-19 Thread Eryk Sun
Eryk Sun added the comment: In Windows, checking for a directory in order to defer to either os_rmdir_impl() or os_unlink_impl() would lead to a redundant directory check. os_unlink_impl() already has to check for a directory in order to delete a directory symlink or mountpoint. I suggest im

[issue46791] Allow os.remove to defer to rmdir

2022-02-18 Thread Dan Snider
New submission from Dan Snider : It appears sometime recently-ish that POSIX updated remove to the following: #include int remove(const char *path); If path does not name a directory, remove(path) shall be equivalent to  unlink(path). If path names a directory, remove(path) shall be eq