summaryrefslogtreecommitdiff
path: root/drivers/windows/file_access_windows.cpp
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2018-03-15 22:21:21 +0100
committerGitHub <noreply@github.com>2018-03-15 22:21:21 +0100
commit9bc0503c9174309dcdaf116ae16ccd9e4d9bce20 (patch)
treeb8b541f778686bf333a802617e2bd37ad41916b9 /drivers/windows/file_access_windows.cpp
parentf8706cbdf2133744174490c4f27eca0ebd3a6480 (diff)
parenta4e64c545406be00c00fe93818994977ae378fb9 (diff)
Merge pull request #17376 from marcelofg55/file_get_path
Added File.get_path and File.get_path_absolute functions
Diffstat (limited to 'drivers/windows/file_access_windows.cpp')
-rw-r--r--drivers/windows/file_access_windows.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 072790876f..e10f4d05e8 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -57,7 +57,8 @@ void FileAccessWindows::check_errors() const {
Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
- String filename = fix_path(p_path);
+ path_src = p_path;
+ path = fix_path(p_path);
if (f)
close();
@@ -78,19 +79,19 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
backend supports utf8 encoding */
struct _stat st;
- if (_wstat(filename.c_str(), &st) == 0) {
+ if (_wstat(path.c_str(), &st) == 0) {
if (!S_ISREG(st.st_mode))
return ERR_FILE_CANT_OPEN;
};
if (is_backup_save_enabled() && p_mode_flags & WRITE && !(p_mode_flags & READ)) {
- save_path = filename;
- filename = filename + ".tmp";
+ save_path = path;
+ path = path + ".tmp";
//print_line("saving instead to "+path);
}
- f = _wfopen(filename.c_str(), mode_string);
+ f = _wfopen(path.c_str(), mode_string);
if (f == NULL) {
last_error = ERR_FILE_CANT_OPEN;
@@ -154,6 +155,17 @@ void FileAccessWindows::close() {
ERR_FAIL_COND(rename_error);
}
}
+
+String FileAccessWindows::get_path() const {
+
+ return path_src;
+}
+
+String FileAccessWindows::get_path_absolute() const {
+
+ return path;
+}
+
bool FileAccessWindows::is_open() const {
return (f != NULL);