Merge pull request #44400 from andy-noisyduck/master

Fix incorrect error messages when writing to compressed or encrypted files
This commit is contained in:
Rémi Verschelde 2020-12-15 19:07:43 +01:00 committed by GitHub
commit f26a765637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -327,14 +327,14 @@ Error FileAccessCompressed::get_error() const {
void FileAccessCompressed::flush() { void FileAccessCompressed::flush() {
ERR_FAIL_COND_MSG(!f, "File must be opened before use."); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode."); ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
// compressed files keep data in memory till close() // compressed files keep data in memory till close()
} }
void FileAccessCompressed::store_8(uint8_t p_dest) { void FileAccessCompressed::store_8(uint8_t p_dest) {
ERR_FAIL_COND_MSG(!f, "File must be opened before use."); ERR_FAIL_COND_MSG(!f, "File must be opened before use.");
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode."); ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
WRITE_FIT(1); WRITE_FIT(1);
write_ptr[write_pos++] = p_dest; write_ptr[write_pos++] = p_dest;

View File

@ -256,7 +256,7 @@ Error FileAccessEncrypted::get_error() const {
} }
void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) { void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode."); ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
if (pos < data.size()) { if (pos < data.size()) {
for (int i = 0; i < p_length; i++) { for (int i = 0; i < p_length; i++) {
@ -272,13 +272,13 @@ void FileAccessEncrypted::store_buffer(const uint8_t *p_src, int p_length) {
} }
void FileAccessEncrypted::flush() { void FileAccessEncrypted::flush() {
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode."); ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
// encrypted files keep data in memory till close() // encrypted files keep data in memory till close()
} }
void FileAccessEncrypted::store_8(uint8_t p_dest) { void FileAccessEncrypted::store_8(uint8_t p_dest) {
ERR_FAIL_COND_MSG(!writing, "File has not been opened in read mode."); ERR_FAIL_COND_MSG(!writing, "File has not been opened in write mode.");
if (pos < data.size()) { if (pos < data.size()) {
data.write[pos] = p_dest; data.write[pos] = p_dest;