From 66ef50cfebbcd650a6b57d896a9ba057a23cea35 Mon Sep 17 00:00:00 2001 From: Cameron Cawley Date: Mon, 1 Jul 2019 17:33:36 +0100 Subject: BACKENDS: Rename and simplify AbstractFSNode::create() --- backends/fs/posix/posix-fs.cpp | 28 +++------------------------- backends/fs/posix/posix-fs.h | 2 +- 2 files changed, 4 insertions(+), 26 deletions(-) (limited to 'backends/fs/posix') 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: /** -- cgit v1.2.3