Пример #1
0
 private static Stream OpenFile(CodeContext /*!*/ context, PlatformAdaptationLayer pal, string name, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         throw PythonOps.OSError(2, "No such file or directory", filename: name);
     }
     try {
         return(pal.OpenFileStream(name, fileMode, fileAccess, fileShare, 1)); // Use a 1 byte buffer size to disable buffering (if the FileStream implementation supports it).
     } catch (UnauthorizedAccessException) {
         throw PythonOps.OSError(13, "Permission denied", name);
     } catch (FileNotFoundException) {
         throw PythonOps.OSError(2, "No such file or directory", name);
     } catch (IOException e) {
         AddFilename(context, name, e);
         throw;
     }
 }