Exemplo n.º 1
0
 internal FileInfo(PPError result, PPFileInfo ppFileInfo)
 {
     QueryResult = result;
     Size        = ppFileInfo.size;
     Type        = (FileType)ppFileInfo.type;
     SystemType  = (FileSystemType)ppFileInfo.system_type;
     /* UTC "wall clock time" according to the browser */
     UTCCreationTime     = PepperSharpUtils.ConvertFromPepperTimestamp(ppFileInfo.creation_time);
     UTCLastAccessTime   = PepperSharpUtils.ConvertFromPepperTimestamp(ppFileInfo.last_access_time);
     UTCLastModifiedTime = PepperSharpUtils.ConvertFromPepperTimestamp(ppFileInfo.last_modified_time);
 }
Exemplo n.º 2
0
        private async Task <PPError> TouchAsyncCore(DateTime lastAccessTime, DateTime lastModifiedTime, MessageLoop messageLoop = null)
        {
            var tcs = new TaskCompletionSource <PPError>();
            EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleTouch += handler;

                if (MessageLoop == null && messageLoop == null)
                {
                    Touch(lastAccessTime, lastModifiedTime);
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var result = (PPError)PPBFileRef.Touch(this,
                                                               PepperSharpUtils.ConvertToPepperTimestamp(lastAccessTime),
                                                               PepperSharpUtils.ConvertToPepperTimestamp(lastModifiedTime),
                                                               new BlockUntilComplete()
                                                               );
                        tcs.TrySetResult(result);
                    }
                                                                   );
                    InvokeHelper(action, messageLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(PPError.Aborted);
            }
            finally
            {
                HandleTouch -= handler;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Touch() Updates time stamps for a file.  You must have write access to the
 /// file if it exists in the external filesystem.
 /// </summary>
 /// <param name="lastAccessTime">The last time the file was accessed.</param>
 /// <param name="lastModifiedTime">The last time the file was modified.</param>
 /// <returns>Ok if all went well</returns>
 public PPError Touch(DateTime lastAccessTime, DateTime lastModifiedTime)
 => (PPError)PPBFileRef.Touch(this,
                              PepperSharpUtils.ConvertToPepperTimestamp(lastAccessTime),
                              PepperSharpUtils.ConvertToPepperTimestamp(lastModifiedTime),
                              new CompletionCallback(OnTouch));
Exemplo n.º 4
0
 /// <summary>
 /// AppendFileRangeToBody() is used to append part or
 /// all of a file, to be uploaded, to the request body. A content-length
 /// request header will be automatically generated.
 /// </summary>
 /// <param name="fileRef">A <code>FileRef</code> containing the file
 /// reference.</param>
 /// <param name="startOffset">An optional starting point offset within the
 /// file.</param>
 /// <param name="length">An optional number of bytes of the file to
 /// be included. If the value is -1, then the sub-range to upload extends
 /// to the end of the file.</param>
 /// <param name="utcExpectedLastModifiedTime">An optional last
 /// modified time stamp used to validate that the file was not modified since
 /// the given time before it was uploaded. The upload will fail with an error
 /// code of <code>ErrorFilechanged</code> if the file has been modified
 /// since the given time. If utcExpectedLastModifiedTime is null, then no
 /// validation is performed.</param>
 /// <returns>true if successful, false if any of the parameters are invalid.</returns>
 public bool AppendFileRangeToBody(FileRef fileRef,
                                   long startOffset,
                                   long length,
                                   DateTime?utcExpectedLastModifiedTime = null)
 => PPBURLRequestInfo.AppendFileToBody(this,
                                       fileRef,
                                       startOffset,
                                       length,
                                       (utcExpectedLastModifiedTime.HasValue) ? PepperSharpUtils.ConvertToPepperTimestamp(utcExpectedLastModifiedTime.Value) : 0) == PPBool.True;