[Windows] Fix windows is_path_invalid, and apply it to directory creation.
This commit is contained in:
parent
41564aaf77
commit
be8f60a78d
3 changed files with 11 additions and 7 deletions
|
@ -31,6 +31,7 @@
|
||||||
#if defined(WINDOWS_ENABLED)
|
#if defined(WINDOWS_ENABLED)
|
||||||
|
|
||||||
#include "dir_access_windows.h"
|
#include "dir_access_windows.h"
|
||||||
|
#include "file_access_windows.h"
|
||||||
|
|
||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "core/os/memory.h"
|
#include "core/os/memory.h"
|
||||||
|
@ -177,6 +178,13 @@ Error DirAccessWindows::make_dir(String p_dir) {
|
||||||
p_dir = fix_path(p_dir);
|
p_dir = fix_path(p_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FileAccessWindows::is_path_invalid(p_dir)) {
|
||||||
|
#ifdef DEBUG_ENABLED
|
||||||
|
WARN_PRINT("The path :" + p_dir + " is a reserved Windows system pipe, so it can't be used for creating directories.");
|
||||||
|
#endif
|
||||||
|
return ERR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
p_dir = p_dir.simplify_path().replace("/", "\\");
|
p_dir = p_dir.simplify_path().replace("/", "\\");
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
|
|
|
@ -60,12 +60,7 @@ void FileAccessWindows::check_errors() const {
|
||||||
|
|
||||||
bool FileAccessWindows::is_path_invalid(const String &p_path) {
|
bool FileAccessWindows::is_path_invalid(const String &p_path) {
|
||||||
// Check for invalid operating system file.
|
// Check for invalid operating system file.
|
||||||
String fname = p_path;
|
String fname = p_path.get_file().get_basename().to_lower();
|
||||||
int dot = fname.find(".");
|
|
||||||
if (dot != -1) {
|
|
||||||
fname = fname.substr(0, dot);
|
|
||||||
}
|
|
||||||
fname = fname.to_lower();
|
|
||||||
return invalid_files.has(fname);
|
return invalid_files.has(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,10 +50,11 @@ class FileAccessWindows : public FileAccess {
|
||||||
|
|
||||||
void _close();
|
void _close();
|
||||||
|
|
||||||
static bool is_path_invalid(const String &p_path);
|
|
||||||
static HashSet<String> invalid_files;
|
static HashSet<String> invalid_files;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static bool is_path_invalid(const String &p_path);
|
||||||
|
|
||||||
virtual String fix_path(const String &p_path) const override;
|
virtual String fix_path(const String &p_path) const override;
|
||||||
virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file
|
virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file
|
||||||
virtual bool is_open() const override; ///< true when file is open
|
virtual bool is_open() const override; ///< true when file is open
|
||||||
|
|
Loading…
Reference in a new issue