diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-03-10 19:47:59 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-03-10 19:47:59 +0000 |
commit | 5c8e82e097272d46caf139eda5bab58d2cbac9a0 (patch) | |
tree | 59e4cfaf47a329a5fa356a610004ef4554397e6d | |
parent | 5fb1e1024fb58d3704261545d63586f1e617f199 (diff) | |
download | rockbox-5c8e82e097272d46caf139eda5bab58d2cbac9a0.tar.gz rockbox-5c8e82e097272d46caf139eda5bab58d2cbac9a0.zip |
You can't open() a directory as a file (at least not for writing)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4359 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/common/file.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/firmware/common/file.c b/firmware/common/file.c index 3a91bda876..5c1db105f4 100644 --- a/firmware/common/file.c +++ b/firmware/common/file.c @@ -160,6 +160,13 @@ int open(const char* pathname, int flags) closedir(dir); return -7; } + } else { + if(file->write && (file->attr & FAT_ATTR_DIRECTORY)) { + errno = EISDIR; + file->busy = false; + closedir(dir); + return -8; + } } closedir(dir); @@ -169,7 +176,7 @@ int open(const char* pathname, int flags) if (file->write && (flags & O_APPEND)) { rc = lseek(fd,0,SEEK_END); if (rc < 0 ) - return rc * 10 - 8; + return rc * 10 - 9; } return fd; |