File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -284,16 +284,19 @@ fn buffered_reader_read(vm: &VirtualMachine, args: PyFuncArgs) -> PyResult {
284284}
285285
286286fn compute_c_flag ( mode : & str ) -> u32 {
287- let flags = match mode {
288- "w" => os:: FileCreationFlags :: O_WRONLY | os:: FileCreationFlags :: O_CREAT ,
289- "x" => {
290- os:: FileCreationFlags :: O_WRONLY
291- | os:: FileCreationFlags :: O_CREAT
292- | os:: FileCreationFlags :: O_EXCL
293- }
294- "a" => os:: FileCreationFlags :: O_APPEND ,
295- "+" => os:: FileCreationFlags :: O_RDWR ,
296- _ => os:: FileCreationFlags :: O_RDONLY ,
287+ let flags = match mode. chars ( ) . next ( ) {
288+ Some ( mode) => match mode {
289+ 'w' => os:: FileCreationFlags :: O_WRONLY | os:: FileCreationFlags :: O_CREAT ,
290+ 'x' => {
291+ os:: FileCreationFlags :: O_WRONLY
292+ | os:: FileCreationFlags :: O_CREAT
293+ | os:: FileCreationFlags :: O_EXCL
294+ }
295+ 'a' => os:: FileCreationFlags :: O_APPEND ,
296+ '+' => os:: FileCreationFlags :: O_RDWR ,
297+ _ => os:: FileCreationFlags :: O_RDONLY ,
298+ } ,
299+ None => os:: FileCreationFlags :: O_RDONLY ,
297300 } ;
298301 flags. bits ( )
299302}
You can’t perform that action at this time.
0 commit comments