diff options
author | Cameron Cawley | 2019-07-01 17:33:36 +0100 |
---|---|---|
committer | Filippos Karapetis | 2019-08-06 07:17:29 +0300 |
commit | 66ef50cfebbcd650a6b57d896a9ba057a23cea35 (patch) | |
tree | 4fff70c1ace46f819798461a4250c62452011543 /backends/fs/posix | |
parent | 8666e9564f25d2f0923ac6e23b74d107a17d645e (diff) | |
download | scummvm-rg350-66ef50cfebbcd650a6b57d896a9ba057a23cea35.tar.gz scummvm-rg350-66ef50cfebbcd650a6b57d896a9ba057a23cea35.tar.bz2 scummvm-rg350-66ef50cfebbcd650a6b57d896a9ba057a23cea35.zip |
BACKENDS: Rename and simplify AbstractFSNode::create()
Diffstat (limited to 'backends/fs/posix')
-rw-r--r-- | backends/fs/posix/posix-fs.cpp | 28 | ||||
-rw-r--r-- | backends/fs/posix/posix-fs.h | 2 |
2 files changed, 4 insertions, 26 deletions
diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index 5b724c291f..507f075db4 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -299,33 +299,11 @@ Common::WriteStream *POSIXFilesystemNode::createWriteStream() { return StdioStream::makeFromPath(getPath(), true); } -bool POSIXFilesystemNode::create(bool isDirectoryFlag) { - bool success; - - if (isDirectoryFlag) { - success = mkdir(_path.c_str(), 0755) == 0; - } else { - int fd = open(_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0755); - success = fd >= 0; - - if (fd >= 0) { - close(fd); - } - } - - if (success) { +bool POSIXFilesystemNode::createDirectory() { + if (mkdir(_path.c_str(), 0755) == 0) setFlags(); - if (_isValid) { - if (_isDirectory != isDirectoryFlag) warning("failed to create %s: got %s", isDirectoryFlag ? "directory" : "file", _isDirectory ? "directory" : "file"); - return _isDirectory == isDirectoryFlag; - } - - warning("POSIXFilesystemNode: %s() was a success, but stat indicates there is no such %s", - isDirectoryFlag ? "mkdir" : "creat", isDirectoryFlag ? "directory" : "file"); - return false; - } - return false; + return _isValid && _isDirectory; } namespace Posix { diff --git a/backends/fs/posix/posix-fs.h b/backends/fs/posix/posix-fs.h index 5ad26ff027..9751ab74f6 100644 --- a/backends/fs/posix/posix-fs.h +++ b/backends/fs/posix/posix-fs.h @@ -68,7 +68,7 @@ public: virtual Common::SeekableReadStream *createReadStream(); virtual Common::WriteStream *createWriteStream(); - virtual bool create(bool isDirectoryFlag); + virtual bool createDirectory(); private: /** |