summaryrefslogtreecommitdiff
path: root/drivers/unix
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/unix')
-rw-r--r--drivers/unix/dir_access_unix.cpp27
-rw-r--r--drivers/unix/dir_access_unix.h5
-rw-r--r--drivers/unix/file_access_unix.cpp5
-rw-r--r--drivers/unix/os_unix.cpp23
-rw-r--r--drivers/unix/packet_peer_udp_posix.cpp28
-rw-r--r--drivers/unix/packet_peer_udp_posix.h28
6 files changed, 104 insertions, 12 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 8b097ad25e..f0e4511b1d 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -66,7 +66,7 @@ bool DirAccessUnix::file_exists(String p_file) {
if (p_file.is_rel_path())
- p_file=current_dir+"/"+p_file;
+ p_file=current_dir.plus_file(p_file);
else
p_file=fix_path(p_file);
@@ -104,7 +104,7 @@ bool DirAccessUnix::dir_exists(String p_dir) {
uint64_t DirAccessUnix::get_modified_time(String p_file) {
if (p_file.is_rel_path())
- p_file=current_dir+"/"+p_file;
+ p_file=current_dir.plus_file(p_file);
else
p_file=fix_path(p_file);
@@ -138,11 +138,9 @@ String DirAccessUnix::get_next() {
//typedef struct stat Stat;
struct stat flags;
- String fname;
- if (fname.parse_utf8(entry->d_name))
- fname=entry->d_name; //no utf8, maybe latin?
+ String fname = fix_unicode_name(entry->d_name);
- String f=current_dir+"/"+fname;
+ String f=current_dir.plus_file(fname);
if (stat(f.utf8().get_data(),&flags)==0) {
@@ -201,8 +199,17 @@ Error DirAccessUnix::make_dir(String p_dir) {
GLOBAL_LOCK_FUNCTION
- p_dir=fix_path(p_dir);
-
+ if (p_dir.is_rel_path())
+ p_dir=get_current_dir().plus_file(p_dir);
+ else
+ p_dir=fix_path(p_dir);
+#if 1
+
+
+ bool success=(mkdir(p_dir.utf8().get_data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)==0);
+ int err = errno;
+
+#else
char real_current_dir_name[2048];
getcwd(real_current_dir_name,2048);
chdir(current_dir.utf8().get_data()); //ascii since this may be unicode or wathever the host os wants
@@ -211,7 +218,7 @@ Error DirAccessUnix::make_dir(String p_dir) {
int err = errno;
chdir(real_current_dir_name);
-
+#endif
if (success) {
return OK;
};
@@ -314,7 +321,7 @@ size_t DirAccessUnix::get_space_left() {
struct statvfs vfs;
if (statvfs(current_dir.utf8().get_data(), &vfs) != 0) {
- return -1;
+ return 0;
};
return vfs.f_bfree * vfs.f_bsize;
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index 9cba1ed3e0..b2f1aed10f 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -51,7 +51,10 @@ class DirAccessUnix : public DirAccess {
String current_dir;
bool _cisdir;
bool _cishidden;
-
+protected:
+
+ virtual String fix_unicode_name(const char* p_name) const { return String::utf8(p_name); }
+
public:
virtual bool list_dir_begin(); ///< This starts dir listing
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 9f24633bd4..2838e7d913 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -124,6 +124,11 @@ void FileAccessUnix::close() {
//unlink(save_path.utf8().get_data());
//print_line("renaming..");
int rename_error = rename((save_path+".tmp").utf8().get_data(),save_path.utf8().get_data());
+
+ if (rename_error && close_fail_notify) {
+ close_fail_notify(save_path);
+ }
+
save_path="";
ERR_FAIL_COND( rename_error != 0);
}
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 359758290f..8cb7c7b698 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -44,6 +44,10 @@
#include "stream_peer_tcp_posix.h"
#include "packet_peer_udp_posix.h"
+#ifdef __APPLE__
+#include <mach-o/dyld.h>
+#endif
+
#ifdef __FreeBSD__
#include <sys/param.h>
#endif
@@ -460,7 +464,7 @@ int OS_Unix::get_processor_count() const {
String OS_Unix::get_data_dir() const {
- String an = Globals::get_singleton()->get("application/name");
+ String an = get_safe_application_name();
if (an!="") {
@@ -508,6 +512,23 @@ String OS_Unix::get_executable_path() const {
realpath(OS::get_executable_path().utf8().get_data(), resolved_path);
return String(resolved_path);
+#elif defined(__APPLE__)
+ char temp_path[1];
+ uint32_t buff_size=1;
+ _NSGetExecutablePath(temp_path, &buff_size);
+
+ char* resolved_path = new char[buff_size + 1];
+
+ if (_NSGetExecutablePath(resolved_path, &buff_size) == 1)
+ WARN_PRINT("MAXPATHLEN is too small");
+
+ String path(resolved_path);
+ delete[] resolved_path;
+
+ return path;
+#elif defined(EMSCRIPTEN)
+ // We return nothing
+ return String();
#else
ERR_PRINT("Warning, don't know how to obtain executable path on this OS! Please override this function properly.");
return OS::get_executable_path();
diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp
index 2111619080..754003f10d 100644
--- a/drivers/unix/packet_peer_udp_posix.cpp
+++ b/drivers/unix/packet_peer_udp_posix.cpp
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* packet_peer_udp_posix.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "packet_peer_udp_posix.h"
#ifdef UNIX_ENABLED
diff --git a/drivers/unix/packet_peer_udp_posix.h b/drivers/unix/packet_peer_udp_posix.h
index b14568eb5f..a11282e5d6 100644
--- a/drivers/unix/packet_peer_udp_posix.h
+++ b/drivers/unix/packet_peer_udp_posix.h
@@ -1,3 +1,31 @@
+/*************************************************************************/
+/* packet_peer_udp_posix.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#ifndef PACKET_PEER_UDP_POSIX_H
#define PACKET_PEER_UDP_POSIX_H