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 renameToImpl(const std::string& path, int options = 0);
|
||||||
void linkToImpl(const std::string& path, int type) const;
|
void linkToImpl(const std::string& path, int type) const;
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl(bool createDirectories = false);
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
FileSizeImpl totalSpaceImpl() const;
|
FileSizeImpl totalSpaceImpl() const;
|
||||||
FileSizeImpl usableSpaceImpl() const;
|
FileSizeImpl usableSpaceImpl() const;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ protected:
|
|||||||
void renameToImpl(const std::string& path, int options = 0);
|
void renameToImpl(const std::string& path, int options = 0);
|
||||||
void linkToImpl(const std::string& path, int type) const;
|
void linkToImpl(const std::string& path, int type) const;
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl(bool createDirectories = false);
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
FileSizeImpl totalSpaceImpl() const;
|
FileSizeImpl totalSpaceImpl() const;
|
||||||
FileSizeImpl usableSpaceImpl() const;
|
FileSizeImpl usableSpaceImpl() const;
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ protected:
|
|||||||
void renameToImpl(const std::string& path, int options = 0);
|
void renameToImpl(const std::string& path, int options = 0);
|
||||||
void linkToImpl(const std::string& path, int type) const;
|
void linkToImpl(const std::string& path, int type) const;
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl(bool createDirectories = false);
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
FileSizeImpl totalSpaceImpl() const;
|
FileSizeImpl totalSpaceImpl() const;
|
||||||
FileSizeImpl usableSpaceImpl() const;
|
FileSizeImpl usableSpaceImpl() const;
|
||||||
|
|||||||
@@ -459,10 +459,15 @@ void FileImpl::removeImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileImpl::createFileImpl()
|
bool FileImpl::createFileImpl(bool createDirectories)
|
||||||
{
|
{
|
||||||
poco_assert (!_path.empty());
|
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);
|
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)
|
if (n != -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -321,10 +321,14 @@ void FileImpl::removeImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileImpl::createFileImpl()
|
bool FileImpl::createFileImpl(bool createDirectories)
|
||||||
{
|
{
|
||||||
poco_assert (!_path.empty());
|
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);
|
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)
|
if (n != -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -377,10 +377,15 @@ void FileImpl::removeImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FileImpl::createFileImpl()
|
bool FileImpl::createFileImpl(bool createDirectories)
|
||||||
{
|
{
|
||||||
poco_assert (!_path.empty());
|
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);
|
HANDLE hFile = CreateFileW(_upath.c_str(), GENERIC_WRITE, 0, 0, CREATE_NEW, 0, 0);
|
||||||
if (hFile != INVALID_HANDLE_VALUE)
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user