예제 #1
0
        private async Task <PPError> OpenAsyncCore(long expected_size, MessageLoop openLoop = null)
        {
            var tcs = new TaskCompletionSource <PPError>();
            EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleOpen += handler;

                if (MessageLoop == null && openLoop == null)
                {
                    Open(expected_size);
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var result = (PPError)PPBFileSystem.Open(this, expected_size,
                                                                 new BlockUntilComplete()
                                                                 );
                        tcs.TrySetResult(result);
                    }
                                                                   );
                    InvokeHelper(action, openLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(PPError.Aborted);
            }
            finally
            {
                HandleOpen -= handler;
            }
        }
예제 #2
0
 /// <summary>
 /// Open() opens the file system. A file system must be opened before running
 /// any other operation on it.
 /// </summary>
 /// <param name="expected_size">
 /// The expected size of the file system.Note that
 /// this does not request quota; to do that, you must either invoke
 /// requestQuota from JavaScript:
 /// http://www.html5rocks.com/en/tutorials/file/filesystem/#toc-requesting-quota
 /// or set the unlimitedStorage permission for Chrome Web Store apps:
 /// http://code.google.com/chrome/extensions/manifest.html#permissions
 /// </param>
 /// <returns>A PPError code</returns>
 public PPError Open(long expected_size)
 => (PPError)PPBFileSystem.Open(this, expected_size, new CompletionCallback(OnOpen));
예제 #3
0
 public FileSystem(Instance instance, FileSystemType type)
 {
     handle = PPBFileSystem.Create(instance, (PPFileSystemType)type);
 }