mirror of
https://github.com/Relintai/sfw.git
synced 2025-01-03 05:09:36 +01:00
Renamed Fileaccess::open to FileAccess::create_and_open.
This commit is contained in:
parent
3bfbc1542e
commit
bddae4352f
@ -1015,14 +1015,14 @@ String DirAccess::get_full_path(const String &p_path) {
|
|||||||
Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
|
Error DirAccess::copy(String p_from, String p_to, int p_chmod_flags) {
|
||||||
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
|
//printf("copy %s -> %s\n",p_from.ascii().get_data(),p_to.ascii().get_data());
|
||||||
Error err;
|
Error err;
|
||||||
FileAccess *fsrc = FileAccess::open(p_from, FileAccess::READ, &err);
|
FileAccess *fsrc = FileAccess::create_and_open(p_from, FileAccess::READ, &err);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
ERR_PRINT("Failed to open " + p_from);
|
ERR_PRINT("Failed to open " + p_from);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileAccess *fdst = FileAccess::open(p_to, FileAccess::WRITE, &err);
|
FileAccess *fdst = FileAccess::create_and_open(p_to, FileAccess::WRITE, &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
fsrc->close();
|
fsrc->close();
|
||||||
memdelete(fsrc);
|
memdelete(fsrc);
|
||||||
|
@ -679,7 +679,7 @@ FileAccess *FileAccess::create() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FileAccess::exists(const String &p_name) {
|
bool FileAccess::exists(const String &p_name) {
|
||||||
FileAccess *f = open(p_name, READ);
|
FileAccess *f = create_and_open(p_name, READ);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -691,7 +691,7 @@ Error FileAccess::reopen(const String &p_path, int p_mode_flags) {
|
|||||||
return _open(p_path, p_mode_flags);
|
return _open(p_path, p_mode_flags);
|
||||||
};
|
};
|
||||||
|
|
||||||
FileAccess *FileAccess::open(const String &p_path, int p_mode_flags, Error *r_error) {
|
FileAccess *FileAccess::create_and_open(const String &p_path, int p_mode_flags, Error *r_error) {
|
||||||
//try packed data first
|
//try packed data first
|
||||||
|
|
||||||
FileAccess *ret = nullptr;
|
FileAccess *ret = nullptr;
|
||||||
@ -1116,7 +1116,7 @@ void FileAccess::store_buffer(const uint8_t *p_src, uint64_t p_length) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_error) {
|
Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_error) {
|
||||||
FileAccess *f = FileAccess::open(p_path, READ, r_error);
|
FileAccess *f = FileAccess::create_and_open(p_path, READ, r_error);
|
||||||
if (!f) {
|
if (!f) {
|
||||||
if (r_error) { // if error requested, do not throw error
|
if (r_error) { // if error requested, do not throw error
|
||||||
return Vector<uint8_t>();
|
return Vector<uint8_t>();
|
||||||
|
@ -126,8 +126,8 @@ public:
|
|||||||
|
|
||||||
virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType
|
virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType
|
||||||
|
|
||||||
static FileAccess *create(); /// Create a file access (for the current platform) this is the only portable way of accessing files.
|
static FileAccess *create(); /// Helper that Creates a file access
|
||||||
static FileAccess *open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files.
|
static FileAccess *create_and_open(const String &p_path, int p_mode_flags, Error *r_error = nullptr); /// Create a file access (for the current platform) this is the only portable way of accessing files.
|
||||||
static bool exists(const String &p_name); ///< return true if a file exists
|
static bool exists(const String &p_name); ///< return true if a file exists
|
||||||
static uint64_t get_modified_time(const String &p_file);
|
static uint64_t get_modified_time(const String &p_file);
|
||||||
static uint32_t get_unix_permissions(const String &p_file);
|
static uint32_t get_unix_permissions(const String &p_file);
|
||||||
|
@ -1671,7 +1671,7 @@ Error Image::save_png(const String &file_name) {
|
|||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileAccess* f = FileAccess::open(file_name, FileAccess::WRITE);
|
FileAccess* f = FileAccess::create_and_open(file_name, FileAccess::WRITE);
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
return FAILED;
|
return FAILED;
|
||||||
|
Loading…
Reference in New Issue
Block a user