@@ -106,13 +106,10 @@ impl GFile {
106
106
arg_into_ref ! ( path) ;
107
107
108
108
let fa = FileAccess :: open ( path, flags) . ok_or_else ( || {
109
- std:: io:: Error :: new (
110
- ErrorKind :: Other ,
111
- format ! (
112
- "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
113
- FileAccess :: get_open_error( )
114
- ) ,
115
- )
109
+ std:: io:: Error :: other ( format ! (
110
+ "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
111
+ FileAccess :: get_open_error( )
112
+ ) )
116
113
} ) ?;
117
114
118
115
Ok ( Self :: from_inner ( fa) )
@@ -133,13 +130,10 @@ impl GFile {
133
130
. compression_mode ( compression_mode)
134
131
. done ( )
135
132
. ok_or_else ( || {
136
- std:: io:: Error :: new (
137
- ErrorKind :: Other ,
138
- format ! (
139
- "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
140
- FileAccess :: get_open_error( )
141
- ) ,
142
- )
133
+ std:: io:: Error :: other ( format ! (
134
+ "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
135
+ FileAccess :: get_open_error( )
136
+ ) )
143
137
} ) ?;
144
138
145
139
Ok ( Self :: from_inner ( fa) )
@@ -157,13 +151,10 @@ impl GFile {
157
151
arg_into_ref ! ( path) ;
158
152
159
153
let fa = FileAccess :: open_encrypted ( path, flags, key) . ok_or_else ( || {
160
- std:: io:: Error :: new (
161
- ErrorKind :: Other ,
162
- format ! (
163
- "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
164
- FileAccess :: get_open_error( )
165
- ) ,
166
- )
154
+ std:: io:: Error :: other ( format ! (
155
+ "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
156
+ FileAccess :: get_open_error( )
157
+ ) )
167
158
} ) ?;
168
159
169
160
Ok ( Self :: from_inner ( fa) )
@@ -182,13 +173,10 @@ impl GFile {
182
173
arg_into_ref ! ( password) ;
183
174
184
175
let fa = FileAccess :: open_encrypted_with_pass ( path, flags, password) . ok_or_else ( || {
185
- std:: io:: Error :: new (
186
- ErrorKind :: Other ,
187
- format ! (
188
- "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
189
- FileAccess :: get_open_error( )
190
- ) ,
191
- )
176
+ std:: io:: Error :: other ( format ! (
177
+ "can't open file {path} in mode {flags:?}; GodotError: {:?}" ,
178
+ FileAccess :: get_open_error( )
179
+ ) )
192
180
} ) ?;
193
181
Ok ( Self :: from_inner ( fa) )
194
182
}
@@ -224,10 +212,9 @@ impl GFile {
224
212
let modified_time = FileAccess :: get_modified_time ( path) ;
225
213
226
214
if modified_time == 0 {
227
- Err ( std:: io:: Error :: new (
228
- ErrorKind :: Other ,
229
- format ! ( "can't retrieve last modified time: {path}" ) ,
230
- ) )
215
+ Err ( std:: io:: Error :: other ( format ! (
216
+ "can't retrieve last modified time: {path}"
217
+ ) ) )
231
218
} else {
232
219
Ok ( modified_time)
233
220
}
@@ -240,10 +227,9 @@ impl GFile {
240
227
let md5 = FileAccess :: get_md5 ( path) ;
241
228
242
229
if md5. is_empty ( ) {
243
- Err ( std:: io:: Error :: new (
244
- ErrorKind :: Other ,
245
- format ! ( "failed to compute file's MD5 checksum: {path}" ) ,
246
- ) )
230
+ Err ( std:: io:: Error :: other ( format ! (
231
+ "failed to compute file's MD5 checksum: {path}"
232
+ ) ) )
247
233
} else {
248
234
Ok ( md5)
249
235
}
@@ -256,10 +242,9 @@ impl GFile {
256
242
let sha256 = FileAccess :: get_sha256 ( path) ;
257
243
258
244
if sha256. is_empty ( ) {
259
- Err ( std:: io:: Error :: new (
260
- ErrorKind :: Other ,
261
- format ! ( "failed to compute file's SHA-256 checksum: {path}" ) ,
262
- ) )
245
+ Err ( std:: io:: Error :: other ( format ! (
246
+ "failed to compute file's SHA-256 checksum: {path}"
247
+ ) ) )
263
248
} else {
264
249
Ok ( sha256)
265
250
}
@@ -684,10 +669,7 @@ impl GFile {
684
669
return Ok ( ( ) ) ;
685
670
}
686
671
687
- Err ( std:: io:: Error :: new (
688
- ErrorKind :: Other ,
689
- format ! ( "GodotError: {:?}" , error) ,
690
- ) )
672
+ Err ( std:: io:: Error :: other ( format ! ( "GodotError: {:?}" , error) ) )
691
673
}
692
674
693
675
// File length cache is stored and kept when possible because `FileAccess::get_length()` turned out to be slowing down
0 commit comments