Esempio n. 1
0
    public bool Load(string path)
    {
        if (!File.Exists(path))
        {
            return(false);
        }

        Clear();

        name = path;
        using (var reader = new BinaryReader(File.OpenRead(path)))
        {
            var count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var file = new VFile {
                    id = i
                };
                file.Deserialize(reader);
                AddFile(file);
            }
            _pos = reader.BaseStream.Position;
        }
        Reindex();
        return(true);
    }
Esempio n. 2
0
 private void SetTemplates()
 {
     _ordIssueFuture = Template.TwOrdIssueFuture;
     if (_configObj.Market.Contains("TWSE"))
     {
         _ordIdn         = TemplateIdn.TwOrdIdnTwse;
         _ordNda         = Template.TwOrdAddTwse;
         _ordQuoteFuture = Template.TwOrdQuoteFutureTwse;
         _ordFm          = TemplateFm.TwOrdTwse;
     }
     else if (_configObj.Market.Contains("GTSM"))
     {
         _ordIdn         = TemplateIdn.TwOrdIdnGtsm;
         _ordNda         = Template.TwOrdAddGtsm;
         _ordQuoteFuture = Template.TwOrdQuoteFutureGtsm;
         _ordFm          = TemplateFm.TwOrdGtsm;
     }
     else if (_configObj.Market.Contains("EMG"))
     {
         _ordIdn         = TemplateIdn.TwOrdIdnEmg;
         _ordNda         = Template.TwOrdAddEmg;
         _ordQuoteFuture = Template.TwOrdQuoteFutureEmg;
         _ordFm          = TemplateFm.TwOrdEmg;
     }
     else
     {
         throw new Exception("The Market you choose does not exist, please change the configuration and choose an existing one.");
     }
 }
Esempio n. 3
0
        public void CreateFaceFiles(int dirId, string dirname)
        {
            if (facedir.SubFiles == null)
            {
                facedir.SubFiles = new List <VFile>();
            }
            facedir.id   = dirId;
            facedir.name = dirname;
            facedir.SubFiles.Clear();

            var cmd = _sqlcon.CreateCommand();

            cmd.CommandText = "select NetFileId,PartNo,tn.FaceId as FaceId,Size,Name from [NetFileMappedTable] as tn join [FaceFileTable] as tf on tn.FaceId= tf.FaceId where dirId=@dirId order by FaceId,PartNo";
            cmd.Parameters.AddWithValue("@dirId", dirId);
            var rd = cmd.ExecuteReader();

            var   mappedNetFiles = new HashSet <int>();
            VFile lastfile       = null;

            while (rd.Read())
            {
                //var fff = rd["NetFileId"];
                //fff.GetType().
                var netfileid = (int)rd["NetFileId"];
                var part      = (short)rd["PartNo"];
                if (part == 0)
                {
                    var f = new VFile()
                    {
                        id       = (int)rd["FaceId"],
                        Name     = (string)rd["Name"],
                        Size     = (Int64)rd["Size"],
                        partFile = new Dictionary <int, int>()
                        {
                            { 0, netfileid }
                        }
                    };
                    facedir.SubFiles.Add(f);
                    lastfile = f;
                }
                else
                {
                    lastfile.partFile[part] = netfileid;
                }
                mappedNetFiles.Add(netfileid);
            }
            //create direct files
            foreach (var x in files)
            {
                if (!mappedNetFiles.Contains(x.Key))
                {
                    var f = new VFile();
                    f.id         = x.Key;
                    f.Name       = x.Value.name;
                    f.Size       = x.Value.size;
                    f.UploadTime = x.Value.uploadTime.ToString();
                    facedir.SubFiles.Add(f);
                }
            }
        }
Esempio n. 4
0
    public static List <VFile> LoadVersions(string filename, bool update = false)
    {
        string rootDir = Path.GetDirectoryName(filename);
        Dictionary <string, VFile> data = update ? _updateData : _baseData;

        data.Clear();
        using (FileStream stream = File.OpenRead(filename))
        {
            var reader = new BinaryReader(stream);
            var list   = new List <VFile>();
            var ver    = reader.ReadInt32();
            GameLog.Log("LoadVersions:" + ver);
            int count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var version = new VFile();
                version.Deserialize(reader);
                list.Add(version);
                data[version.name] = version;
                var dir = string.Format("{0}/{1}", rootDir, Path.GetDirectoryName(version.name));
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
            }
            return(list);
        }
    }
Esempio n. 5
0
    private IEnumerator UpdateCopy(IList <VFile> versions, string basePath)
    {
        VFile version = versions[0];

        if (version.name.Equals(Versions.Dataname))
        {
            var request = UnityWebRequest.Get(basePath + version.name);
            request.downloadHandler = new DownloadHandlerFile(_savePath + version.name);
            var req = request.SendWebRequest();
            while (!req.isDone)
            {
                OnMessage("正在复制文件");
                OnProgress(req.progress);
                yield return(null);
            }

            request.Dispose();
        }
        else
        {
            for (var index = 0; index < versions.Count; index++)
            {
                var item    = versions[index];
                var request = UnityWebRequest.Get(basePath + item.name);
                request.downloadHandler = new DownloadHandlerFile(_savePath + item.name);
                yield return(request.SendWebRequest());

                request.Dispose();
                OnMessage(string.Format("正在复制文件:{0}/{1}", index, versions.Count));
                OnProgress(index * 1f / versions.Count);
            }
        }
    }
Esempio n. 6
0
        private void ProcessFaceFile(VFile file)
        {
            var DirectAccessSet = new HashSet <string>()
            {
                "jpg", "txt", "mp3", "mp4"
            };

            string ext = Path.GetExtension(file.Name).Substring(1).ToLower();

            if (DirectAccessSet.Contains(ext))
            {
                if (file.Size < 10 * 1024 * 1024)
                {
                    var sid = _lanz.get_shareId(file.id);
                    var stm = Lanzou.get_fileStream(sid);
                    OpenStreamByProperApplication(stm, file.Name, ext);
                }
                else
                {
                    downloadFaceFile(file);
                }
            }
            else
            {
                downloadFaceFile(file);
            }
        }
Esempio n. 7
0
 static RC BackupTruncateFile(VFile file, int size)
 {
     long current;
     RC rc = file.get_FileSize(out current);
     if (rc == RC.OK && current > size)
         rc = file.Truncate(size);
     return rc;
 }
Esempio n. 8
0
    public void AddFile(string path, long len, string hash)
    {
        var file = new VFile {
            name = path, len = len, hash = hash
        };

        AddFile(file);
    }
Esempio n. 9
0
        protected VFile FindFiles(string pathString)
        {
            pathString = pathString.Trim('\\').Replace("\\\\", "\\");
            if (pathString == "")
            {
                if (RootNode == null || !RootNode.IsLoaded)
                {
                    LoadFile(RootNode);
                }
                return(RootNode);
            }
            string[] path = pathString.Split('\\');

            VFile currentNode = RootNode;

            foreach (string dirName in path)
            {
                try
                {
                    if (currentNode.GetType() != typeof(Folder))
                    {
                        return(null);
                    }

                    if (!((Folder)currentNode).IsLoaded)
                    {
                        //И так работает все медленно, не будем ставить lock если это можно
                        lock (currentNode)
                        {
                            if (!((Folder)currentNode).IsLoaded)
                            {
                                LoadFile((Folder)currentNode);
                            }
                        }
                    }


                    //currentNode = currentNode.ChildNodes.First(value => value.Name == dirName);
                    currentNode = ((Folder)currentNode).FindInChilds(dirName);
                    if (currentNode == null)
                    {
                        _log.Debug("Не нашел: " + pathString);
                        return(null);
                    }
                }
                catch (Exception)
                {
                    _log.Debug("Не нашел(exception): " + pathString);
                    return(null);
                }
            }
            if (currentNode.GetType() == typeof(Folder) && !((Folder)currentNode).IsLoaded)
            {
                LoadFile((Folder)currentNode);
            }
            return(currentNode);
        }
Esempio n. 10
0
        public CinematicLocal()
        {
            image  = null;
            status = CinStatus.FMV_EOF;
            buf    = null;
            iFile  = null;

            qStatus0 = new byte *[32768];
            qStatus1 = new byte *[32768];
        }
Esempio n. 11
0
 public TreeItemsList(VFile file, Typeface fontface, double fontsize)
 {
     this._fontsize    = fontsize;
     this.typeface     = fontface;
     this.myfile       = file;
     this.root         = new DirectoryList(string.Empty, "<Root>", null);
     this.cacheViews   = new Dictionary <DirectoryList, List <ItemViewModel> >();
     this._directories = new Dictionary <string, DirectoryList>(StringComparer.OrdinalIgnoreCase);
     this._directories.Add(string.Empty, this.root);
 }
Esempio n. 12
0
        public unsafe static int ov_openFile(VFile f, OggVorbis_File vf)
        {
            vf.memset();
            ov_callbacks callbacks;

            callbacks.read_func  = Marshal.GetFunctionPointerForDelegate <ov_callbacks.ReadFuncDelegate>(FS_ReadOGG);
            callbacks.seek_func  = Marshal.GetFunctionPointerForDelegate <ov_callbacks.SeekFuncDelegate>(FS_SeekOGG);
            callbacks.close_func = Marshal.GetFunctionPointerForDelegate <ov_callbacks.CloseFuncDelegate>(FS_CloseOGG);
            callbacks.tell_func  = Marshal.GetFunctionPointerForDelegate <ov_callbacks.TellFuncDelegate>(FS_TellOGG);
            return(ov_open_callbacks(f, vf, null, -1, callbacks));
        }
Esempio n. 13
0
        public void ReadFromSaveGame(VFile savefile)
        {
            savefile.Read(out enabled);
            savefile.Read(out type);
            savefile.Read(out regCount);
            savefile.ReadTMany(out regs, regs.Length);

            savefile.Read(out int len); savefile.ReadASCII(out name, len);

            var.ReadFromSaveGame(savefile);
        }
Esempio n. 14
0
 // Constructs the class.  Call Open() to open a wave file for reading.
 // Then call Read() as needed.  Calling the destructor or Close() will close the file.
 public WaveFile()
 {
     mpwfx                 = default;
     mhmmio                = null;
     mdwSize               = 0;
     mseekBase             = 0;
     mbIsReadingFromMemory = false;
     mpbData               = null;
     ogg   = null;
     isOgg = false;
 }
Esempio n. 15
0
        // Opens a wave file for reading
        public int Open(string strFileName, out WaveformatEx pwfx)
        {
            pwfx = default;
            mbIsReadingFromMemory = false;

            mpbData    = null;
            mpbDataCur = 0;

            if (strFileName == null)
            {
                return(-1);
            }

            var name = strFileName;

            // note: used to only check for .wav when making a build
            name = PathX.SetFileExtension(name, ".ogg");
            if (fileSystem.ReadFile(name, out var _) != -1)
            {
                return(OpenOGG(name, out pwfx));
            }

            mpwfx = default;

            mhmmio = fileSystem.OpenFileRead(strFileName);
            if (mhmmio == null)
            {
                mdwSize = 0; return(-1);
            }
            if (mhmmio.Length <= 0)
            {
                mhmmio = null; return(-1);
            }
            if (ReadMMIO() != 0)
            {
                Close(); return(-1);
            }                                            // ReadMMIO will fail if its an not a wave file
            mfileTime = mhmmio.Timestamp;
            if (ResetFile() != 0)
            {
                Close(); return(-1);
            }

            // After the reset, the size of the wav file is mck.cksize so store it now
            mdwSize  = (int)(mck.cksize / sizeof(short));
            mMemSize = (int)mck.cksize;

            if (mck.cksize != 0xffffffff)
            {
                pwfx = mpwfx.Format; return(0);
            }
            return(-1);
        }
Esempio n. 16
0
        public void WriteToSaveGame(VFile savefile)
        {
            savefile.Write(enabled);
            savefile.Write(type);
            savefile.Write(regCount);
            savefile.WriteTMany(regs);

            var len = name.Length;

            savefile.Write(len); savefile.Write(Encoding.ASCII.GetBytes(name), len);

            var.WriteToSaveGame(savefile);
        }
Esempio n. 17
0
        public virtual void ReadFromSaveGame(VFile savefile, GameBustOutWindow game)
        {
            savefile.Read(out x);
            savefile.Read(out y);
            savefile.Read(out width);
            savefile.Read(out height);

            savefile.Read(out powerup);
            savefile.Read(out isBroken);

            savefile.Read(out int index);
            ent = game.entities[index];
        }
Esempio n. 18
0
 public static void ExportObj_Sub_mesh()
 {
     if (VDialog.DisplayDialog("你是否要将物件Mesh存为 OBJ 格式,并存为多个Sub-Mesh"))
     {
         if (Selection.gameObjects.Length == 0)
         {
             Debug.Log("Didn't Export Any Meshes; Nothing was Selected!"); return;
         }
         string meshName = Selection.gameObjects[0].name;
         makeSubmeshes = true;
         VFile.SaveFile(SaveOBJFile, "obj");
     }
 }
Esempio n. 19
0
 public static void ExportObj()
 {
     if (EditorUtility.DisplayDialog("V", "你是否要将物件Mesh存为 Obj 格式,并将Mesh合并", "OK"))
     {
         if (Selection.gameObjects.Length == 0)
         {
             Debug.Log("Didn't Export Any Meshes; Nothing was Selected!"); return;
         }
         string meshName = Selection.gameObjects[0].name;
         makeSubmeshes = false;
         VFile.SaveFile(SaveOBJFile, "obj");
     }
 }
Esempio n. 20
0
        public override NtStatus DeleteDirectory(string filename, DokanFileInfo info)
        {
            VFile node = FindFiles(filename);

            if (node == null && node.GetType() == typeof(Folder) && ((Folder)node).Property.ContainsKey("inStorage"))
            {
                RootNode.Childs.Remove(node);
                API.VkStorage.Remove(StorageKey, ((Folder)node).Property["gid"]);
                return(DokanResult.Success);
            }

            return(DokanResult.Error);
        }
Esempio n. 21
0
        public virtual void WriteToSaveGame(VFile savefile)
        {
            savefile.Write(x);
            savefile.Write(y);
            savefile.Write(width);
            savefile.Write(height);

            savefile.Write(powerup);
            savefile.Write(isBroken);

            var index = ent.game.entities.FindIndex(x => x == ent);

            savefile.Write(index);
        }
Esempio n. 22
0
        void RoQShutdown()
        {
            if (status == CinStatus.FMV_IDLE)
            {
                return;
            }
            status = CinStatus.FMV_IDLE;

            if (iFile != null)
            {
                fileSystem.CloseFile(iFile); iFile = null;
            }

            fileName = "";
        }
Esempio n. 23
0
        public override bool InitFromFile(string qpath, bool looping)
        {
            ushort RoQID;

            Close();

            inMemory        = false;
            animationLength = 100000;

            fileName = !qpath.Contains('/') && !qpath.Contains('\\')
                ? $"video/{qpath}"
                : qpath;
            iFile = fileSystem.OpenFileRead(fileName);
            if (iFile == null)
            {
                return(false);
            }
            ROQSize = iFile.Length;

            this.looping = looping;

            CIN_HEIGHT      = DEFAULT_CIN_HEIGHT;
            CIN_WIDTH       = DEFAULT_CIN_WIDTH;
            samplesPerPixel = 4;
            startTime       = 0;
            buf             = null;

            iFile.Read(file, 16);
            RoQID = (ushort)(file[0] + (file[1] * 256));

            frameRate = file[6];
            if (frameRate == 32f)
            {
                frameRate = 1000f / 32f;
            }

            if (RoQID == ROQ_FILE)
            {
                RoQ_init();
                status = CinStatus.FMV_PLAY;
                ImageForTime(0);
                status = looping ? CinStatus.FMV_PLAY : CinStatus.FMV_IDLE;
                return(true);
            }

            RoQShutdown();
            return(false);
        }
Esempio n. 24
0
File: Get.cs Progetto: DnAp/VKDrive
        public static VFile WallPostToFolder(JObject jToken, bool isTop = false)
        {
            var wallPost = jToken.ToObject <SerializationObject.WallPost>();

            // Я хотел значек музыки или фотки засунуть если они есть в посте
            var folderName = wallPost.Text.Trim();

            var folder = new Folder("")
            {
                CreationTime  = wallPost.Date,
                LastWriteTime = wallPost.Date
            };

            JToken jArray;

            if (jToken.TryGetValue("copy_history", out jArray))
            {
                // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
                foreach (JObject historyItem in (JArray)jArray)
                {
                    if (isTop && folderName.Length == 0)
                    {
                        folderName = historyItem.GetValue("text").ToString().Trim();
                    }

                    var copyFolder = WallPostToFolder(historyItem);
                    folder.ChildsAdd(copyFolder);
                }
            }
            folder.FileName = VFile.ClearName(wallPost.Date.ToString("yyyy-MM-dd ") + folderName, false);
            if (wallPost.Text.Trim().Length > 0)
            {
                folder.ChildsAdd(new PlainText("Текст.txt", wallPost.Text.Trim()));
            }
            //folder.ChildsAdd(new PlainText("debug.json", jToken.ToString()));

            if (jToken.TryGetValue("attachments", out jArray))
            {
                // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
                foreach (var attachFile in (JArray)jArray)
                {
                    folder.ChildsAdd(ConvertAttachToFile((JObject)attachFile));
                }
            }
            folder.IsLoaded = true;
            return(folder);
        }
Esempio n. 25
0
    public static void BuildVersions(string outputPath, string[] bundles, int version)
    {
        var path = outputPath + "/" + Filename;

        if (File.Exists(path))
        {
            File.Delete(path);
        }

        var dataPath = outputPath + "/" + Dataname;

        if (File.Exists(dataPath))
        {
            File.Delete(dataPath);
        }

        var disk = new VDisk();

        foreach (var file in bundles)
        {
            using (var fs = File.OpenRead(outputPath + "/" + file))
            {
                disk.AddFile(file, fs.Length, Utility.GetCRC32Hash(fs));
            }
        }

        disk.name = dataPath;
        disk.Save();

        using (var stream = File.OpenWrite(path))
        {
            var writer = new BinaryWriter(stream);
            writer.Write(version);
            writer.Write(disk.files.Count + 1);
            using (var fs = File.OpenRead(dataPath))
            {
                var file = new VFile {
                    name = Dataname, len = fs.Length, hash = Utility.GetCRC32Hash(fs)
                };
                file.Serialize(writer);
            }
            foreach (var file in disk.files)
            {
                file.Serialize(writer);
            }
        }
    }
Esempio n. 26
0
        public virtual void WriteToSaveGame(VFile savefile)
        {
            game.WriteSaveGameString(materialName, savefile);

            savefile.Write(width);
            savefile.Write(height);
            savefile.Write(visible);

            savefile.WriteT(entColor);
            savefile.WriteT(position);
            savefile.Write(rotation);
            savefile.Write(rotationSpeed);
            savefile.WriteT(velocity);

            savefile.Write(fadeIn);
            savefile.Write(fadeOut);
        }
Esempio n. 27
0
        public override (byte[], int) Read(VFile file, int length, long offset)
        {
            //Prevent overflow to say... next tar header
            int actual_read_length = Math.Min((int)(file.Size - offset), length);

            byte[]   buffer    = new byte[length];
            int      bytesread = 0;
            TarState state     = states[file.AbsolutePath];

            using (FileStream fs = File.OpenRead(filepath))
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    reader.BaseStream.Position = state.offset_in_tar_file + offset;
                    bytesread = reader.Read(buffer, bytesread, actual_read_length);
                }
            return(buffer, bytesread);
        }
Esempio n. 28
0
        public virtual void WriteToSaveGame(VFile savefile)
        {
            savefile.Write(visible);

            game.WriteSaveGameString(materialName, savefile);

            savefile.Write(width);
            savefile.Write(height);

            savefile.WriteT(color);
            savefile.WriteT(position);
            savefile.WriteT(velocity);

            savefile.Write(powerup);
            savefile.Write(removed);
            savefile.Write(fadeOut);
        }
Esempio n. 29
0
        static void FileWriterInit(Context ctx, VFile file, FileWriter p, long start)
        {
            p._memset();
            int pageSize = ctx.DBs[0].Bt.GetPageSize();

            p.Buffer.data = (byte[])C._tagalloc(ctx, pageSize);
            if (p.Buffer.data == null)
            {
                p.FWErr = RC.NOMEM;
            }
            else
            {
                p.BufEnd        = p.BufStart = (start % pageSize);
                p.WriteOffset   = start - p.BufStart;
                p.Buffer.length = pageSize;
                p.File          = file;
            }
        }
Esempio n. 30
0
        /// <summary>
        /// todo нифига не законченый вариант
        /// </summary>
        /// <param name="ownerId"></param>
        /// <returns></returns>
        public VFile[] PaginationSimpleStart(int ownerId)
        {
            var code      = string.Format(@"var lastPosts = API.wall.get({{owner_id: {0}, offset: 0, count: 500, filter: ""all""}});
if(lastPosts.count < 500) {{
	var firstPost = API.wall.get({{ owner_id: {0}, offset: lastPosts.count - 1, count: 1, filter: ""all""}});
	result.push({{ count: lastPosts.count, lastPosts: lastPosts.items, firstPost: firstPost.items[0]}});
}}else{{
	result.push(lastPosts);
}}", ownerId);
            var apiResult = (JObject)Vkapi.Instance.StartTaskSync(new ApiExpression(code));
            var count     = (int)apiResult.GetValue("count");

            JToken lastPpst;

            if (apiResult.TryGetValue("lastPosts", out lastPpst))
            {
                var resultFile = new List <VFile>();

                var firstPost = apiResult.GetValue("firstPost").ToObject <SerializationObject.WallPost>();
                var lastPosts = (JArray)apiResult.GetValue("lastPosts");
                var lastPost  = lastPosts.First.ToObject <SerializationObject.WallPost>();


                if (lastPost.Date.Year != firstPost.Date.Year)
                {
                    for (var i = firstPost.Date.Year; i <= lastPost.Date.Year; i++)
                    {
                        resultFile.Add(new Folder(i.ToString()));
                    }
                }
                return(resultFile.ToArray());
            }
            var items  = (JArray)apiResult.GetValue("items");
            var result = new VFile[items.Count];
            var j      = 0;

            // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
            foreach (JObject jToken in items)
            {
                result[j] = Get.WallPostToFolder(jToken, true);
                j++;
            }
            return(result);
        }