aboutsummaryrefslogtreecommitdiff
path: root/backends/fs/posix
diff options
context:
space:
mode:
authorCameron Cawley2019-07-01 17:33:36 +0100
committerFilippos Karapetis2019-08-06 07:17:29 +0300
commit66ef50cfebbcd650a6b57d896a9ba057a23cea35 (patch)
tree4fff70c1ace46f819798461a4250c62452011543 /backends/fs/posix
parent8666e9564f25d2f0923ac6e23b74d107a17d645e (diff)
downloadscummvm-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.cpp28
-rw-r--r--backends/fs/posix/posix-fs.h2
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:
/**