mirror of
https://github.com/pocoproject/poco.git
synced 2025-12-11 02:25:59 +01:00
* #4202 Checked if the path exists, create one if not * Addressed comments * fix(Poco::File): resolve compile errors related to createfile. --------- Co-authored-by: capak07 <69026837+capak07@users.noreply.github.com>
This commit is contained in:
@@ -62,7 +62,7 @@ protected:
|
||||
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;
|
||||
|
||||
@@ -61,7 +61,7 @@ protected:
|
||||
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;
|
||||
|
||||
@@ -62,7 +62,7 @@ protected:
|
||||
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;
|
||||
|
||||
@@ -459,10 +459,15 @@ void FileImpl::removeImpl()
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::createFileImpl()
|
||||
bool FileImpl::createFileImpl(bool createDirectories)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -321,10 +321,14 @@ void FileImpl::removeImpl()
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::createFileImpl()
|
||||
bool FileImpl::createFileImpl(bool createDirectories)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -377,10 +377,15 @@ void FileImpl::removeImpl()
|
||||
}
|
||||
|
||||
|
||||
bool FileImpl::createFileImpl()
|
||||
bool FileImpl::createFileImpl(bool createDirectories)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user