public static Stream CreateTemporaryStorage(Func <int, byte[]> acquireBuffer, Action <byte[]> releaseBuffer)
        {
            TemporaryDataStorage temporaryDataStorage = new TemporaryDataStorage(acquireBuffer, releaseBuffer);
            Stream result = temporaryDataStorage.OpenWriteStream(false);

            temporaryDataStorage.Release();
            return(result);
        }
Пример #2
0
 // Token: 0x06000C3A RID: 3130 RVA: 0x0006BF00 File Offset: 0x0006A100
 public static void Configure(int defaultMaximumSize, int defaultBlockSize, string defaultPath, Func <int, byte[]> defaultAcquireBuffer, Action <byte[]> defaultReleaseBuffer)
 {
     TemporaryDataStorage.DefaultBufferMaximumSize = defaultMaximumSize;
     TemporaryDataStorage.DefaultBufferBlockSize   = defaultBlockSize;
     TemporaryDataStorage.DefaultPath          = defaultPath;
     TemporaryDataStorage.DefaultAcquireBuffer = defaultAcquireBuffer;
     TemporaryDataStorage.DefaultReleaseBuffer = defaultReleaseBuffer;
     TemporaryDataStorage.Configured           = false;
     TemporaryDataStorage.Configure();
 }
Пример #3
0
 // Token: 0x06000C44 RID: 3140 RVA: 0x0006C5A4 File Offset: 0x0006A7A4
 private static string ValidatePath(string path)
 {
     try
     {
         if (Path.IsPathRooted(path))
         {
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path, TemporaryDataStorage.GetDirectorySecurity());
             }
             new FileIOPermission(FileIOPermissionAccess.Write, path).Demand();
         }
         else
         {
             path = null;
         }
     }
     catch (PathTooLongException)
     {
         path = null;
     }
     catch (DirectoryNotFoundException)
     {
         path = null;
     }
     catch (IOException)
     {
         path = null;
     }
     catch (UnauthorizedAccessException)
     {
         path = null;
     }
     catch (ArgumentException)
     {
         path = null;
     }
     catch (NotSupportedException)
     {
         path = null;
     }
     return(path);
 }
Пример #4
0
 // Token: 0x06000C38 RID: 3128 RVA: 0x0006BEBA File Offset: 0x0006A0BA
 public TemporaryDataStorage(Func <int, byte[]> acquireBuffer, Action <byte[]> releaseBuffer)
 {
     TemporaryDataStorage.Configure();
     this.buffer = new TemporaryDataStorage.VirtualBuffer(TemporaryDataStorage.DefaultBufferBlockSize, TemporaryDataStorage.DefaultBufferMaximumSize, (acquireBuffer != null) ? acquireBuffer : TemporaryDataStorage.DefaultAcquireBuffer, (releaseBuffer != null) ? releaseBuffer : TemporaryDataStorage.DefaultReleaseBuffer);
 }
Пример #5
0
 // Token: 0x06000C41 RID: 3137 RVA: 0x0006C1C4 File Offset: 0x0006A3C4
 private static void Configure()
 {
     if (TemporaryDataStorage.Configured)
     {
         return;
     }
     lock (TemporaryDataStorage.configurationLockObject)
     {
         if (!TemporaryDataStorage.Configured)
         {
             int    num  = TemporaryDataStorage.DefaultBufferMaximumSize;
             int    num2 = TemporaryDataStorage.DefaultBufferBlockSize;
             string text = TemporaryDataStorage.DefaultPath;
             IList <CtsConfigurationSetting> configuration = ApplicationServices.Provider.GetConfiguration(null);
             foreach (CtsConfigurationSetting ctsConfigurationSetting in configuration)
             {
                 if (ctsConfigurationSetting.Name.Equals("TemporaryStorage", StringComparison.OrdinalIgnoreCase))
                 {
                     foreach (CtsConfigurationArgument ctsConfigurationArgument in ctsConfigurationSetting.Arguments)
                     {
                         if (ctsConfigurationArgument.Name.Equals("Path", StringComparison.OrdinalIgnoreCase))
                         {
                             text = ctsConfigurationArgument.Value.Trim();
                         }
                         else if (ctsConfigurationArgument.Name.Equals("MaximumBufferSize", StringComparison.OrdinalIgnoreCase))
                         {
                             if (!int.TryParse(ctsConfigurationArgument.Value.Trim(), out num))
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num = TemporaryDataStorage.DefaultBufferMaximumSize;
                             }
                             else if (num < 16 || num > 10240)
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num = TemporaryDataStorage.DefaultBufferMaximumSize;
                             }
                             else
                             {
                                 num *= 1024;
                             }
                         }
                         else if (ctsConfigurationArgument.Name.Equals("BufferIncrement", StringComparison.OrdinalIgnoreCase))
                         {
                             if (!int.TryParse(ctsConfigurationArgument.Value.Trim(), out num2))
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num2 = TemporaryDataStorage.DefaultBufferBlockSize;
                             }
                             else if (num2 < 4 || num2 > 64)
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num2 = TemporaryDataStorage.DefaultBufferBlockSize;
                             }
                             else
                             {
                                 num2 *= 1024;
                             }
                         }
                         else
                         {
                             ApplicationServices.Provider.LogConfigurationErrorEvent();
                         }
                     }
                 }
             }
             if (num < num2 || num % num2 != 0)
             {
                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                 num  = TemporaryDataStorage.DefaultBufferMaximumSize;
                 num2 = TemporaryDataStorage.DefaultBufferBlockSize;
             }
             TemporaryDataStorage.DefaultBufferMaximumSize = num;
             TemporaryDataStorage.DefaultBufferBlockSize   = num2;
             string systemTempPath = TemporaryDataStorage.GetSystemTempPath();
             if (text != null)
             {
                 text = TemporaryDataStorage.ValidatePath(text);
             }
             if (text == null)
             {
                 text = systemTempPath;
             }
             TempFileStream.SetTemporaryPath(text);
             TemporaryDataStorage.Configured = true;
         }
     }
 }
Пример #6
0
 // Token: 0x06000C3F RID: 3135 RVA: 0x0006C17F File Offset: 0x0006A37F
 internal static string GetTempPath()
 {
     TemporaryDataStorage.Configure();
     return(TempFileStream.Path);
 }