public async Task <List <Directory> > GetDirectories(VDisk vdisk) { var response = await client.GetAsync($"vdisks/{vdisk.Id}/replicas/local/dirs"); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsStringAsync() .ContinueWith(t => JsonConvert.DeserializeObject <List <Directory> >(t.Result))); } return(null); }
public async Task <Partition?> GetPartition(VDisk vDisk, string partition) { var result = await client.GetAsync($"vdisks/{vDisk.Id}/partitions/{partition}"); if (!result.IsSuccessStatusCode) { return(null); } var content = await result.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <Partition>(content)); }
public async Task <long?> CountRecordsOnVDisk(VDisk vDisk) { try { var result = await client.GetAsync($"vdisks/{vDisk.Id}/records/count"); if (!result.IsSuccessStatusCode) { return(null); } return(long.Parse(await result.Content.ReadAsStringAsync())); } catch (HttpRequestException) { } catch (TaskCanceledException) { } return(null); }
public async Task <List <string> > GetPartitions(VDisk vDisk) { var response = await client.GetAsync($"vdisks/{vDisk.Id}/partitions"); if (response.IsSuccessStatusCode) { return(await response.Content.ReadAsStringAsync() .ContinueWith(t => JsonConvert.DeserializeAnonymousType(t.Result, new { Partitions = new List <string>() }).Partitions)); } return(null); }
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); } } }
private static async Task DeleteOldPartitions(Uri uri, VDisk vDisk, List <string> partitions) { using var api = new BobApiClient(uri); foreach (var partition in partitions) { var partitionObject = await api.GetPartition(vDisk, partition); if (partitionObject is null) { LogError($"Failed to get partition {partition} on {vDisk}"); } else if (GetDateTimeFromTimestamp(partitionObject?.Timestamp) < configuration.Threshold) { await api.DeletePartition(vDisk, partitionObject?.Timestamp); LogInfo($"Deleted partition {partition} on {vDisk}"); } } }
static void Main(string[] args) { //starts VDisk vd = VDisk.Create(1024); pt = new PartitionTable(vd); //initializes partition part = Partitioner.Create(pt, 1024); PraxisFormatter.format(part, "system"); //formats praxpart = new PraxisPartition(part); PraxisPartitionTable.Add(praxpart); //creates file Praxis.IO.File.Create("/system/test1.txt", Encoding.UTF8.GetBytes("Hello, World. This is test 1.".PadLeft(1976, 'x'))); Praxis.IO.File.Create("/system/test2.txt", Encoding.UTF8.GetBytes("Hello, World. This is test 2.")); Praxis.IO.File.Create("/system/test3.txt", Encoding.UTF8.GetBytes("Hello, World. This is test 3.")); //writes contents to console Console.Write(Encoding.UTF8.GetString(Praxis.IO.File.Read("/system/test1.txt")));//Encoding.UTF8.GetString(Praxis.IO.File.get("system", 0)).Replace(((char)0).ToString(), "")); Console.ReadKey(); }
public Program(string[] args) { _consoleLock = new object(); LogProvider.OnLogWrite += LogProviderOnOnLogWrite; LogProvider.Start(); if (args.Length <= 0) { return; } if (args[0] == "server") { KrPatchServer patchServer = new KrPatchServer(); patchServer.Start(); Setting setting = new Setting(); KrGameServer gameServer = new KrGameServer(setting); gameServer.Start(); while (Console.ReadKey().Key != ConsoleKey.E) { Thread.Sleep(300); } gameServer.Stop(); } if (args.Length >= 3 && args[0] == "vdisk-extract") { VDisk vDisk = new VDisk(); vDisk.Open(args[1]); vDisk.Extract(args[2]); } if (args.Length >= 3 && args[0] == "vdisk-extract-all") { DirectoryInfo sourceFolder = new DirectoryInfo(args[1]); DirectoryInfo destinationFolder = new DirectoryInfo(args[2]); FileInfo[] files = sourceFolder.GetFiles("*.SNP", SearchOption.AllDirectories); foreach (FileInfo file in files) { VDisk vDisk = new VDisk(); vDisk.Open(file.FullName); vDisk.Extract(destinationFolder.FullName); } } if (args.Length >= 4 && args[0] == "vdisk-archive") { VDisk vDisk = new VDisk(); vDisk.AddFolder(args[1], args[2]); vDisk.Save(args[3]); } if (args.Length >= 2 && args[0] == "vdisk-test") { VDisk vDisk = new VDisk(); vDisk.Open(args[1]); vDisk.Save(args[2]); } LogProvider.Stop(); Console.WriteLine("Program Closed"); }
public async Task DeletePartition(VDisk vDisk, long?partition) { await client.DeleteAsync($"vdisks/{vDisk.Id}/partitions/{partition}"); }