Beispiel #1
0
 public int ReadFile(String filename, Byte[] buffer, ref uint readBytes,
                     long offset, DokanFileInfo info)
 {
     lock (info)
     {
         logger.Debug("ReadFile {0} bytes from {1}", buffer.Length, offset);
         try
         {
             PutioFileHandle handle = this.Mounter.PutioFileSystem.GetHandleByGuid((Guid)info.Context);
             // if (this.FindPutioFSItem(filename) == null)
             //    return DokanNet.ERROR_FILE_NOT_FOUND;
             if (offset != handle.Position)
             {
                 handle.Seek(offset);
             }
             readBytes = (uint)handle.Read(buffer, 0, buffer.Length);
         }
         catch (KeyNotFoundException)
         {
             logger.Debug("Trying to read from a closed file.");
             return(-1);
         }
         return(0);
     }
 }
Beispiel #2
0
        public void PutioFileReadTest()
        {
            FileInfo        finfo         = new FileInfo(test_local_file);
            PutioFile       remote_file   = new PutioFile(new PutioFsTestDataProvider(finfo.Name, finfo.FullName, 660, finfo.Length, false, Constants.LocalStoragePath), null);
            PutioFileHandle remote_stream = remote_file.Open();
            //FileStream remote_stream = File.Open(remote_file.DataProvider.LocalStorageFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            FileStream local_stream = File.Open(test_local_file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            byte[] local_data  = new byte[11952];
            byte[] remote_data = new byte[11952];

            local_stream.Seek(367043856, SeekOrigin.Begin);
            local_stream.Read(local_data, 0, local_data.Length);
            // remote_stream.Seek(367043856, SeekOrigin.Begin);
            remote_stream.Seek(367043856);
            remote_stream.Read(remote_data, 0, remote_data.Length);


            CollectionAssert.AreEqual(local_data, remote_data);
        }
Beispiel #3
0
        public void PutioFileVLCReadTest()
        {
            PutioFile       remote_file   = new PutioFile(new PutioFsTestDataProvider("660.avi", test_local_file, 660, 697080622, false, Constants.LocalStoragePath), null);
            PutioFileHandle remote_stream = remote_file.Open();
            FileStream      local_stream  = File.Open(test_local_file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            foreach (int[] p in vlc_read_positions)
            {
                byte[] local_data  = new byte[p[0]];
                byte[] remote_data = new byte[p[0]];

                remote_stream.Seek(p[1]);
                int remote_read = remote_stream.Read(remote_data, 0, p[0]);
                local_stream.Seek(p[1], SeekOrigin.Begin);
                int local_read = local_stream.Read(local_data, 0, p[0]);

                Assert.AreEqual(local_read, remote_read);
                CollectionAssert.AreEqual(remote_data, local_data);
            }
            Debug.WriteLine(":(");
        }