summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-17 22:40:54 +0200
committerGitHub <noreply@github.com>2017-09-17 22:40:54 +0200
commit73b8e5acab7e389d7ce8cfb48d533ba74cd86133 (patch)
tree46c6a9cbc85eba19818fa5b9f8ef3c2a6615c194
parent65ef19abe3cb95df72f5256b17ec6667ed26cf6d (diff)
parent3528b1e571dee24917b0141232f135e29bf088ba (diff)
Merge pull request #11362 from marcelofg55/fix_x11_export
Fix x11 exported executables not getting the +x flag
-rw-r--r--core/os/dir_access.cpp7
-rw-r--r--core/os/dir_access.h2
-rw-r--r--core/os/file_access.h2
-rw-r--r--drivers/unix/file_access_unix.cpp9
-rw-r--r--drivers/unix/file_access_unix.h2
-rw-r--r--editor/editor_export.cpp18
-rw-r--r--editor/editor_export.h4
-rw-r--r--platform/x11/export/export.cpp1
8 files changed, 42 insertions, 3 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index f24d6d16ca..1437e7cdfc 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -292,7 +292,7 @@ String DirAccess::get_full_path(const String &p_path, AccessType p_access) {
return full;
}
-Error DirAccess::copy(String p_from, String p_to) {
+Error DirAccess::copy(String p_from, String p_to, int chmod_flags) {
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
Error err;
@@ -329,6 +329,11 @@ Error DirAccess::copy(String p_from, String p_to) {
fdst->store_8(fsrc->get_8());
}
+ if (err == OK && chmod_flags != -1) {
+ fdst->close();
+ err = fdst->_chmod(p_to, chmod_flags);
+ }
+
memdelete(fsrc);
memdelete(fdst);
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 6ad8b4c49b..7fa3ce5cf1 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -89,7 +89,7 @@ public:
static bool exists(String p_dir);
virtual size_t get_space_left() = 0;
- virtual Error copy(String p_from, String p_to);
+ virtual Error copy(String p_from, String p_to, int chmod_flags = -1);
virtual Error rename(String p_from, String p_to) = 0;
virtual Error remove(String p_name) = 0;
diff --git a/core/os/file_access.h b/core/os/file_access.h
index 8e5728f525..151c41c263 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -140,6 +140,8 @@ public:
virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType
+ virtual Error _chmod(const String &p_path, int p_mod) {}
+
static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files.
static FileAccess *create_for_path(const String &p_path);
static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = NULL); /// Create a file access (for the current platform) this is the only portable way of accessing files.
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 80565c5b02..e19bc738cb 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -274,6 +274,15 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) {
};
}
+Error FileAccessUnix::_chmod(const String &p_path, int p_mod) {
+ int err = chmod(p_path.utf8().get_data(), p_mod);
+ if (!err) {
+ return OK;
+ }
+
+ return FAILED;
+}
+
FileAccess *FileAccessUnix::create_libc() {
return memnew(FileAccessUnix);
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 6e5110431f..c5ab8821be 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -78,6 +78,8 @@ public:
virtual uint64_t _get_modified_time(const String &p_file);
+ virtual Error _chmod(const String &p_path, int p_mod);
+
FileAccessUnix();
virtual ~FileAccessUnix();
};
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index d08a595fd2..ad9bc4a662 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -1246,9 +1246,13 @@ Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_pr
}
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
- da->copy(template_path, p_path);
+ Error err = da->copy(template_path, p_path, get_chmod_flags());
memdelete(da);
+ if (err != OK) {
+ return err;
+ }
+
String pck_path = p_path.get_basename() + ".pck";
return save_pack(p_preset, pck_path);
@@ -1302,5 +1306,17 @@ void EditorExportPlatformPC::get_platform_features(List<String> *r_features) {
}
}
+int EditorExportPlatformPC::get_chmod_flags() const {
+
+ return chmod_flags;
+}
+
+void EditorExportPlatformPC::set_chmod_flags(int p_flags) {
+
+ chmod_flags = p_flags;
+}
+
EditorExportPlatformPC::EditorExportPlatformPC() {
+
+ chmod_flags = -1;
}
diff --git a/editor/editor_export.h b/editor/editor_export.h
index b6ea4fd889..50379b9683 100644
--- a/editor/editor_export.h
+++ b/editor/editor_export.h
@@ -319,6 +319,7 @@ class EditorExportPlatformPC : public EditorExportPlatform {
Set<String> extra_features;
bool use64;
+ int chmod_flags;
public:
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
@@ -347,6 +348,9 @@ public:
void add_platform_feature(const String &p_feature);
virtual void get_platform_features(List<String> *r_features);
+ int get_chmod_flags() const;
+ void set_chmod_flags(int p_flags);
+
EditorExportPlatformPC();
};
diff --git a/platform/x11/export/export.cpp b/platform/x11/export/export.cpp
index 59b1a44247..fdb43c9ae0 100644
--- a/platform/x11/export/export.cpp
+++ b/platform/x11/export/export.cpp
@@ -50,6 +50,7 @@ void register_x11_exporter() {
platform->set_release_64("linux_x11_64_release");
platform->set_debug_64("linux_x11_64_debug");
platform->set_os_name("X11");
+ platform->set_chmod_flags(0755);
EditorExport::get_singleton()->add_export_platform(platform);
}