Example #1
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);
        }
Example #2
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(":(");
        }
Example #3
0
        public int CreateFile(String filename, FileAccess access, FileShare share,
                              FileMode mode, FileOptions options, DokanFileInfo info)
        {
            lock (info)
            {
                if (access != FileAccess.Read)
                {
                    return(-DokanNet.ERROR_ACCESS_DENIED);
                }


                PutioFsItem fs_item = this.FindPutioFSItem(filename);

                if (fs_item == null)
                {
                    return(-DokanNet.ERROR_FILE_NOT_FOUND);
                }

                if (fs_item.IsDirectory)
                {
                    info.IsDirectory = true;
                }
                else
                {
                    PutioFile putio_file = (PutioFile)fs_item;
                    // if (putio_file.ReachedHandleLimit())
                    //    return DokanNet.ERROR_SHARING_VIOLATION;
                    PutioFileHandle handle = putio_file.Open();
                    this.Mounter.PutioFileSystem.AddHandle(handle);
                    info.Context = handle.Guid;
                    logger.Debug("CreateFile: {0} - {1}", filename, handle);
                }

                return(0);
            }
        }
Example #4
0
 public void Initialize()
 {
     this.Finfo      = new FileInfo(test_local_file);
     this.RemoteFile = new PutioFile(new PutioFsTestDataProvider(this.Finfo.Name, this.Finfo.FullName, 660, this.Finfo.Length, false, Constants.LocalStoragePath), null);
     this.Cache      = new LocalFileCache(this.RemoteFile);
 }