File tree 6 files changed +23
-8
lines changed
6 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ class DirAccess : public RefCounted {
68
68
virtual String _get_root_string () const ;
69
69
70
70
AccessType get_access_type () const ;
71
- String fix_path (String p_path) const ;
71
+ virtual String fix_path (String p_path) const ;
72
72
73
73
template <class T >
74
74
static Ref<DirAccess> _create_builtin () {
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ class FileAccess : public RefCounted {
81
81
static void _bind_methods ();
82
82
83
83
AccessType get_access_type () const ;
84
- String fix_path (const String &p_path) const ;
84
+ virtual String fix_path (const String &p_path) const ;
85
85
virtual Error open_internal (const String &p_path, int p_mode_flags) = 0; // /< open a file
86
86
virtual uint64_t _get_modified_time (const String &p_file) = 0;
87
87
virtual void _set_access_type (AccessType p_access);
Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ struct DirAccessWindowsPrivate {
59
59
WIN32_FIND_DATAW fu; // unicode version
60
60
};
61
61
62
+ String DirAccessWindows::fix_path (String p_path) const {
63
+ String r_path = DirAccess::fix_path (p_path);
64
+ if (r_path.is_absolute_path () && !r_path.is_network_share_path () && r_path.length () > MAX_PATH) {
65
+ r_path = " \\\\ ?\\ " + r_path.replace (" /" , " \\ " );
66
+ }
67
+ return r_path;
68
+ }
69
+
62
70
// CreateFolderAsync
63
71
64
72
Error DirAccessWindows::list_dir_begin () {
@@ -158,19 +166,14 @@ Error DirAccessWindows::make_dir(String p_dir) {
158
166
p_dir = fix_path (p_dir);
159
167
if (p_dir.is_relative_path ()) {
160
168
p_dir = current_dir.path_join (p_dir);
169
+ p_dir = fix_path (p_dir);
161
170
}
162
171
163
172
p_dir = p_dir.simplify_path ().replace (" /" , " \\ " );
164
173
165
174
bool success;
166
175
int err;
167
176
168
- if (!p_dir.is_network_share_path ()) {
169
- p_dir = " \\\\ ?\\ " + p_dir;
170
- // Add "\\?\" to the path to extend max. path length past 248, if it's not a network share UNC path.
171
- // See https://msdn.microsoft.com/en-us/library/windows/desktop/aa363855(v=vs.85).aspx
172
- }
173
-
174
177
success = CreateDirectoryW ((LPCWSTR)(p_dir.utf16 ().get_data ()), nullptr );
175
178
err = GetLastError ();
176
179
Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ class DirAccessWindows : public DirAccess {
53
53
bool _cisdir = false ;
54
54
bool _cishidden = false ;
55
55
56
+ protected:
57
+ virtual String fix_path (String p_path) const override ;
58
+
56
59
public:
57
60
virtual Error list_dir_begin () override ; // /< This starts dir listing
58
61
virtual String get_next () override ;
Original file line number Diff line number Diff line change @@ -68,6 +68,14 @@ bool FileAccessWindows::is_path_invalid(const String &p_path) {
68
68
return invalid_files.has (fname);
69
69
}
70
70
71
+ String FileAccessWindows::fix_path (const String &p_path) const {
72
+ String r_path = FileAccess::fix_path (p_path);
73
+ if (r_path.is_absolute_path () && !r_path.is_network_share_path () && r_path.length () > MAX_PATH) {
74
+ r_path = " \\\\ ?\\ " + r_path.replace (" /" , " \\ " );
75
+ }
76
+ return r_path;
77
+ }
78
+
71
79
Error FileAccessWindows::open_internal (const String &p_path, int p_mode_flags) {
72
80
if (is_path_invalid (p_path)) {
73
81
#ifdef DEBUG_ENABLED
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class FileAccessWindows : public FileAccess {
54
54
static HashSet<String> invalid_files;
55
55
56
56
public:
57
+ virtual String fix_path (const String &p_path) const override ;
57
58
virtual Error open_internal (const String &p_path, int p_mode_flags) override ; // /< open a file
58
59
virtual bool is_open () const override ; // /< true when file is open
59
60
You can’t perform that action at this time.
0 commit comments