diff --git a/Foundation/include/Poco/File_WIN32U.h b/Foundation/include/Poco/File_WIN32U.h index a88d8334cd..4c7c6f1c28 100644 --- a/Foundation/include/Poco/File_WIN32U.h +++ b/Foundation/include/Poco/File_WIN32U.h @@ -62,7 +62,7 @@ class Foundation_API FileImpl void renameToImpl(const std::string& path, int options = 0); void linkToImpl(const std::string& path, int type) const; void removeImpl(); - bool createFileImpl(); + bool createFileImpl(bool createDirectories = false); bool createDirectoryImpl(); FileSizeImpl totalSpaceImpl() const; FileSizeImpl usableSpaceImpl() const; diff --git a/Foundation/src/File_UNIX.cpp b/Foundation/src/File_UNIX.cpp index 9261a9a367..2039c1d658 100644 --- a/Foundation/src/File_UNIX.cpp +++ b/Foundation/src/File_UNIX.cpp @@ -459,10 +459,15 @@ void FileImpl::removeImpl() } -bool FileImpl::createFileImpl() +bool FileImpl::createFileImpl(bool createDirectories = false) { poco_assert (!_path.empty()); + if(createDirectories) { + Path p(_path); + p.makeDirectory(); + } + int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (n != -1) { diff --git a/Foundation/src/File_VX.cpp b/Foundation/src/File_VX.cpp index ce23993773..6875326ee2 100644 --- a/Foundation/src/File_VX.cpp +++ b/Foundation/src/File_VX.cpp @@ -321,10 +321,14 @@ void FileImpl::removeImpl() } -bool FileImpl::createFileImpl() +bool FileImpl::createFileImpl(bool createDirectories = false) { poco_assert (!_path.empty()); + if(createDirectories) { + Path p(_path); + p.makeDirectory(); + } int n = open(_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if (n != -1) { diff --git a/Foundation/src/File_WIN32U.cpp b/Foundation/src/File_WIN32U.cpp index f4cab98d6c..ef01d08eb3 100644 --- a/Foundation/src/File_WIN32U.cpp +++ b/Foundation/src/File_WIN32U.cpp @@ -377,10 +377,15 @@ void FileImpl::removeImpl() } -bool FileImpl::createFileImpl() +bool FileImpl::createFileImpl(bool createDirectories = false) { poco_assert (!_path.empty()); + if(createDirectories) { + Path p(_path); + p.makeDirectory(); + } + HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0); if (hFile != INVALID_HANDLE_VALUE) {