public Dir FindOrCreate(string path, bool mightBeFile = true) { int i = path.IndexOf('/'); if (i > -1) { Dir dir = FindOrCreate(path.Substring(0, i), false); return(dir.FindOrCreate(path.Substring(i + 1), true)); } // if the name is at the end of a path and contains a "." // we assume it is a file (unless it is "." by itself) if (mightBeFile && path != "." && path.Contains(".")) { Files.Add(path); return(this); } Dir child; if (Dirs.ContainsKey(path)) { child = Dirs[path]; } else { child = new Dir(path); Dirs.Add(path, child); } return(child); }
Dirs ReverseDir(Dirs d) { switch (d) { case Dirs.N: return(Dirs.S); case Dirs.NE: return(Dirs.SW); case Dirs.E: return(Dirs.W); case Dirs.SE: return(Dirs.NW); case Dirs.S: return(Dirs.N); case Dirs.SW: return(Dirs.NE); case Dirs.W: return(Dirs.E); case Dirs.NW: return(Dirs.SE); default: return(Dirs.NONE); } }
public MovingStartButton(int start, int end, Dirs dir) { pos = start; this.end = end; this.dir = dir; Moving = true; }
private void SearchSubDir(DirectoryInfo dir, bool isCount) { if (isCount) { foreach (FileInfo file in dir.GetFiles()) { Size += file.Length; } } DirectoryInfo[] subDirs = dir.GetDirectories(); if (subDirs != null && subDirs.Length > 0) { foreach (DirectoryInfo subDir in subDirs) { if (String.Compare(subDir.Name, "Debug", true) == 0) { Dirs.Add(subDir.FullName); FoundDir(subDir.FullName); SearchSubDir(subDir, true); } else { SearchSubDir(subDir, isCount); } } } }
private static void InitializeProcess() { if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD)) { WriteLine("Platform is not supported."); Exit(-0xFFFFFFF); return; } Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { OutputEncoding = Encoding.Unicode; } JsonConvert.DefaultSettings = () => new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, Culture = CultureInfo.InvariantCulture }; if (GetEnvironmentVariable("WT_SESSION") == null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { SetEnvironmentVariable($"RUNE_EMOJI_USE", "0"); SetEnvironmentVariable($"RUNE_COLOR_USE", "0"); SetEnvironmentVariable($"RUNE_NIER_USE", "0"); SetEnvironmentVariable($"NO_COLOR", "true"); ForegroundColor = ConsoleColor.Gray; WriteLine($"no windows-terminal: coloring, emoji and nier has disabled."); ForegroundColor = ConsoleColor.White; } Dirs.Ensure(); Config.Ensure(); }
public void Add(params GestureDir[] newDirs) { foreach (var d in newDirs) { Dirs.Add(d); } }
public Sprite GetD(Dirs d) { switch (d) { case Dirs.N: return(dpads[1]); case Dirs.NE: return(dpads[2]); case Dirs.E: return(dpads[3]); case Dirs.SE: return(dpads[4]); case Dirs.S: return(dpads[5]); case Dirs.SW: return(dpads[6]); case Dirs.W: return(dpads[7]); case Dirs.NW: return(dpads[8]); default: return(dpads[0]); } }
public Dir FindOrCreate(string path) { int i = path.IndexOf('/'); if (i > -1) { Dir dir = FindOrCreate(path.Substring(0, i)); return(dir.FindOrCreate(path.Substring(i + 1))); } // if the path contains a "." it is a file, unless it is "." by itself if (path != "." && path.Contains(".")) { Files.Add(path); return(this); } Dir child; if (Dirs.ContainsKey(path)) { child = Dirs[path]; } else { child = new Dir(path); Dirs.Add(path, child); } return(child); }
// Update is called once per frame void FixedUpdate() { if (pI.JoystickInput() != new Vector3()) { outCompass = pI.CompassInput(); outAngle = (int)outCompass; outVec = pI.JoystickInput(); //transform.Translate(Quaternion.Euler(0.0f, 0.0f, (int)pI.CompassInput()) * new Vector3(0.0f, 1.0f, 0.0f) * Time.fixedDeltaTime); } if (pI.LTButtonDown) { transform.Translate(new Vector3(0.0f, -1.0f, 0.0f)); } if (pI.RTButtonDown) { transform.Translate(new Vector3(0.0f, 1.0f, 0.0f)); } if (pI.ButtonDown(Button.B)) { transform.Translate(new Vector3(1.0f, 0.0f, 0.0f)); } if (pI.ButtonDown(Button.X)) { transform.Translate(new Vector3(-1.0f, 0.0f, 0.0f)); } //transform.Translate(pI.JoystickInput() * Time.fixedDeltaTime * 10.0f); }
Vector3 DirLookup(Dirs d) { switch (d) { case Dirs.N: return(new Vector3(0.0f, 1.0f, 0.0f)); case Dirs.NE: return(new Vector3(1.0f, 1.0f, 0.0f)); case Dirs.E: return(new Vector3(1.0f, 0.0f, 0.0f)); case Dirs.SE: return(new Vector3(1.0f, -1.0f, 0.0f)); case Dirs.S: return(new Vector3(0.0f, -1.0f, 0.0f)); case Dirs.SW: return(new Vector3(-1.0f, -1.0f, 0.0f)); case Dirs.W: return(new Vector3(-1.0f, 0.0f, 0.0f)); case Dirs.NW: return(new Vector3(-1.0f, 1.0f, 0.0f)); default: return(new Vector3(-1.0f, 1.0f, 0.0f)); } }
private bool checkMov(Dirs dir) { // if a wall is detected, movement is impossible if (dir == Dirs.up) { if (!Physics2D.OverlapCircle(vUp, 0.2f, layerImpass)) { return(true); } } else if (dir == Dirs.down) { if (!Physics2D.OverlapCircle(vDown, 0.2f, layerImpass)) { return(true); } } else if (dir == Dirs.left) { if (!Physics2D.OverlapCircle(vLeft, 0.2f, layerImpass)) { return(true); } } else if (dir == Dirs.right) { if (!Physics2D.OverlapCircle(vRight, 0.2f, layerImpass)) { return(true); } } return(false); }
public void AddDir(Dir dir) { if (!ContainsDir(dir)) { Dirs.Add(GetDir(dir)); dirs += dir.GetHashCode(); } }
public override bool Equals(object obj) { var o = obj as Gesture; return(o != null && o.GestureButton == GestureButton && Dirs.SequenceEqual(o.Dirs) && Modifier == o.Modifier); }
public void ClearTestDirectoryTest() { foreach (var dir in Dirs) { Client.DeleteDirectoryTask(dir, true).Wait(); } Dirs.All(dir => Client.DirectoryExistsTask(dir).Result == false).Should().Be.True(); }
public DirsSetupViewModel() { SelectProgDirCommand = new DelegateCommand(SelectProgDir); SelectReportDirCommand = new DelegateCommand(SelectReportDir); SelectSafeLocateCommand = new DelegateCommand(SelectSafeLocateProgram); Dirs = ServerDirManager.Inst; Dirs.LoadDirs(); }
static Neytiri() { _traceDir = Dirs.DirByCodebase(Dirs.TraceDir); if (!Directory.Exists(_traceDir)) { Directory.CreateDirectory(_traceDir); } }
public Edge(int x, int y, Dirs dir) { if ((dir != Dirs.W) && (dir != Dirs.S)) { throw new ArgumentException("Edges must be West or South."); } this.x = x; this.y = y; this.dir = dir; }
public Dirs co( Dirs dirs, Dir doc ) { return(new Dirs( nilnul.obj.seq.convert_._AppendX.Append(dirs, doc) )); //throw new NotImplementedException(); }
private void SelectProgDir() { FolderBrowserDialog fbDlg = new FolderBrowserDialog(); if (fbDlg.ShowDialog() == DialogResult.OK) { Dirs.MeasureProgDirectory = fbDlg.SelectedPath; Dirs.SaveDirs(); } }
private void SelectedPcdDirectory() { FolderBrowserDialog fbDlg = new FolderBrowserDialog(); if (fbDlg.ShowDialog() == DialogResult.OK) { Dirs.PcdmisReportsDirectory = fbDlg.SelectedPath; Dirs.SaveDirs(); } }
public Face Neighbour(Dirs dir, int dist = 1) { if (!offsets.ContainsKey(dir)) { throw new ArgumentException("The direction you requested is not recognized."); } Tuple <int, int> val = offsets[dir]; return(new Face(this.x + (val.Item1 * dist), this.y + (val.Item2 * dist))); }
void ConnectNeighbors(Chunk c, Chunk n, Dir dir) { if (n == null) { return; } int d = (int)dir; c.neighbors[d] = n; n.neighbors[Dirs.Opp(d)] = c; }
public void Remove(DbRemoteTree remoteTree) { if (remoteTree.Type == RemoteType.dir) { Dirs.Remove(remoteTree); } else { Items.Remove(remoteTree); } }
} // ConnectWithServer /// <summary>Показать файлы и папки</summary> public void ShowFilesAndDirs(string path) { ServerFS.Clear(); Files.Clear(); Dirs.Clear(); DataGridMain.ItemsSource = null; GetFileList(path); GetDirList(path); DataGridMain.ItemsSource = ServerFS; } // ShowFilesAndDirs
protected override void OnFixtureTearDown() { Task.WaitAll(Dirs.Select(dir => Client.DeleteDirectoryTask(dir, true)).ToArray()); ClearFilesAsync(Client, RemoteFileDir); Client.DeleteDirectoryTask(RemoteFileDir).IgnoreExceptions().Wait(); ClearFilesAsync(Client, MovedDirectoryName); Client.DeleteDirectoryTask(MovedDirectoryName).IgnoreExceptions().Wait(); base.OnFixtureTearDown(); }
public bool InSelection(string path) { if (Paths.Any(x => string.Compare(x, path, IgnoreCase) == 0)) { return(SelectMatchedPath()); } if (Dirs.Any(x => path.StartsWith(x + "/", IgnoreCase, CultureInfo.InvariantCulture))) { return(SelectMatchedPath()); } return(!SelectMatchedPath()); }
/// <summary> /// 对所有元素进行排序 /// </summary> public void Sort() { foreach (var item in Dirs) { if (item.Dirs.Count > 0 || item.Items.Count > 0) { item.Sort(); } } Dirs.Sort((x, y) => string.Compare(x.Name, y.Name)); Items.Sort((x, y) => string.Compare(x.Name, y.Name)); }
IEnumerator Turn(Transform t, Dirs target, float step) { Quaternion qtarget = Quaternion.Euler(0, 0, (float)target); Quaternion rot = t.rotation; while (rot != qtarget) { rot = Quaternion.RotateTowards(rot, qtarget, step); t.rotation = rot; yield return(null); } }
public void CreateDirectoryTest() { ClearTestDirectoryTest(); foreach (var dir in Dirs) { Client.CreateDirectoryTask(dir).Result.Should().Be.True(); } Dirs.All(dir => Client.DirectoryExistsTask(dir).Result).Should().Be.True(); Client.ListDirectoryDetailTask().Result.RunEach(path => Console.WriteLine(path.FullName)); }
/// <summary> /// 创建日志对象的新实例,根据指定的日志文件路径和指定的日志文件创建类型 /// </summary> /// <param name="p">日志文件保存路径</param> /// <param name="t">日志文件创建方式的枚举</param> public Log(string p, LogType t) { Dirs.isExitOrCreate(p); if (msgs == null) { state = true; path = p; type = t; msgs = new Queue <Msg>(); Thread thread = new Thread(work); thread.Start(); } }
/// <summary> /// Получить строковое обозначение директории на SCADA-Сервере /// </summary> protected string DirToString(Dirs directory) { switch (directory) { case Dirs.Cur: return "[Srez]" + Path.DirectorySeparatorChar; case Dirs.Hour: return "[Hr]" + Path.DirectorySeparatorChar; case Dirs.Min: return "[Min]" + Path.DirectorySeparatorChar; case Dirs.Events: return "[Ev]" + Path.DirectorySeparatorChar; case Dirs.BaseDAT: return "[Base]" + Path.DirectorySeparatorChar; case Dirs.Itf: return "[Itf]" + Path.DirectorySeparatorChar; default: return ""; } }
/// <summary> /// Принять дату и время изменения файла от SCADA-Сервера. /// В случае отсутствия файла возвращается минимальная дата /// </summary> public DateTime ReceiveFileAge(Dirs dir, string fileName) { Monitor.Enter(tcpLock); DateTime result = DateTime.MinValue; string filePath = DirToString(dir) + fileName; errMsg = ""; try { if (RestoreConnection()) { #if DETAILED_LOG WriteAction(string.Format(Localization.UseRussian ? "Приём даты и времени изменения файла {0} от SCADA-Сервера" : "Receive date and time of file {0} modification from SCADA-Server", filePath), Log.ActTypes.Action); #endif commState = CommStates.WaitResponse; tcpClient.ReceiveTimeout = commSettings.ServerTimeout; // отправка запроса даты и времени изменения файла int cmdLen = 6 + fileName.Length; byte[] buf = new byte[cmdLen]; buf[0] = (byte)(cmdLen % 256); buf[1] = (byte)(cmdLen / 256); buf[2] = 0x0C; buf[3] = 0x01; buf[4] = (byte)dir; buf[5] = (byte)fileName.Length; Array.Copy(Encoding.Default.GetBytes(fileName), 0, buf, 6, fileName.Length); netStream.Write(buf, 0, cmdLen); // приём даты и времени изменения файла buf = new byte[12]; netStream.Read(buf, 0, 12); // обработка даты и времени изменения файла if (CheckDataFormat(buf, 0x0C)) { double dt = BitConverter.ToDouble(buf, 4); result = dt == 0.0 ? DateTime.MinValue : Arithmetic.DecodeDateTime(dt); commState = CommStates.Authorized; } else { errMsg = string.Format(Localization.UseRussian ? "Неверный формат ответа SCADA-Сервера на запрос даты и времени изменения файла {0}" : "Incorrect SCADA-Server response to file modification date and time request", filePath); WriteAction(errMsg, Log.ActTypes.Error); commState = CommStates.Error; } } } catch (Exception ex) { errMsg = string.Format(Localization.UseRussian ? "Ошибка при приёме даты и времени изменения файла {0} от SCADA-Сервера: " : "Error receiving date and time of file {0} modification from SCADA-Server: ", filePath) + ex.Message; WriteAction(errMsg, Log.ActTypes.Exception); Disconnect(); } finally { RestoreReceiveTimeout(); Monitor.Exit(tcpLock); } return result; }
/// <summary> /// Получить полное имя файла /// </summary> private string GetFullFileName(Dirs dir, string fileName) { switch (dir) { case Dirs.Cur: return settings.ArcDir + @"Cur\" + fileName; case Dirs.Hr: return settings.ArcDir + @"Hour\" + fileName; case Dirs.Min: return settings.ArcDir + @"Min\" + fileName; case Dirs.Ev: return settings.ArcDir + @"Events\" + fileName; case Dirs.BaseDAT: return settings.BaseDATDir + fileName; case Dirs.Itf: return settings.ItfDir + fileName; case Dirs.CurCopy: return settings.ArcCopyDir + @"Cur\" + fileName; case Dirs.HrCopy: return settings.ArcCopyDir + @"Hour\" + fileName; case Dirs.MinCopy: return settings.ArcCopyDir + @"Min\" + fileName; default: // Dirs.EvCopy return settings.ArcCopyDir + @"Events\" + fileName; } }
/// <summary> /// Получить строковое обозначение директории на SCADA-Сервере /// </summary> protected string DirToString(Dirs directory) { switch (directory) { case Dirs.Cur: return "[Srez]\\"; case Dirs.Hour: return "[Hr]\\"; case Dirs.Min: return "[Min]\\"; case Dirs.Events: return "[Ev]\\"; case Dirs.BaseDAT: return "[Base]\\"; case Dirs.Itf: return "[Itf]\\"; default: return ""; } }
/// <summary> /// Принять файл от SCADA-Сервера /// </summary> protected bool ReceiveFile(Dirs dir, string fileName, Stream inStream) { bool result = false; string filePath = DirToString(dir) + fileName; try { #if DETAILED_LOG WriteAction(string.Format(Localization.UseRussian ? "Приём файла {0} от SCADA-Сервера" : "Receive file {0} from SCADA-Server", filePath), Log.ActTypes.Action); #endif commState = CommStates.WaitResponse; tcpClient.ReceiveTimeout = commSettings.ServerTimeout; const int dataSize = 10240; // размер запрашиваемых данных 10 кБ const byte dataSizeL = dataSize % 256; const byte dataSizeH = dataSize / 256; byte[] buf = new byte[6 + dataSize]; // буфер отправляемых и получаемых данных bool open = true; // выполняется открытие файла bool stop = false; // признак завершения приёма данных while (!stop) { if (open) { // отправка команды открытия файла и чтения данных byte fileNameLen = (byte)fileName.Length; int cmdLen = 7 + fileNameLen; buf[0] = (byte)(cmdLen % 256); buf[1] = (byte)(cmdLen / 256); buf[2] = 0x08; buf[3] = (byte)dir; buf[4] = fileNameLen; Array.Copy(Encoding.Default.GetBytes(fileName), 0, buf, 5, fileNameLen); buf[cmdLen - 2] = dataSizeL; buf[cmdLen - 1] = dataSizeH; netStream.Write(buf, 0, cmdLen); } else { // отправка команды чтения данных из файла buf[0] = 0x05; buf[1] = 0x00; buf[2] = 0x0A; buf[3] = dataSizeL; buf[4] = dataSizeH; netStream.Write(buf, 0, 5); } // приём результата открытия файла и считанных данных byte cmdNum = buf[2]; int headerLen = open ? 6 : 5; int bytesRead = netStream.Read(buf, 0, headerLen); int dataSizeRead = 0; // размер считанных из файла данных if (bytesRead == headerLen) { dataSizeRead = buf[headerLen - 2] + 256 * buf[headerLen - 1]; if (0 < dataSizeRead && dataSizeRead <= dataSize) bytesRead += ReadNetStream(buf, headerLen, dataSizeRead); } if (CheckDataFormat(buf, cmdNum, bytesRead) && bytesRead == dataSizeRead + headerLen) { if (open) { open = false; if (buf[3] > 0) // файл открыт { inStream.Write(buf, 6, dataSizeRead); commState = CommStates.Authorized; stop = dataSizeRead < dataSize; } else { errMsg = string.Format(Localization.UseRussian ? "SCADA-Серверу не удалось открыть файл {0}" : "SCADA-Server unable to open file {0}", filePath); WriteAction(errMsg, Log.ActTypes.Action); commState = CommStates.NotReady; stop = true; } } else { inStream.Write(buf, 5, dataSizeRead); commState = CommStates.Authorized; stop = dataSizeRead < dataSize; } } else { errMsg = string.Format(Localization.UseRussian ? "Неверный формат ответа SCADA-Сервера на команду открытия или чтения из файла {0}" : "Incorrect SCADA-Server response to open file or read from file {0} command ", filePath); WriteAction(errMsg, Log.ActTypes.Error); commState = CommStates.Error; stop = true; } } // определение результата if (commState == CommStates.Authorized) { if (inStream.Length > 0) inStream.Position = 0; result = true; } } catch (Exception ex) { errMsg = string.Format(Localization.UseRussian ? "Ошибка при приёме файла {0} от SCADA-Сервера: " : "Error receiving file {0} from SCADA-Server: ", filePath) + ex.Message; WriteAction(errMsg, Log.ActTypes.Exception); Disconnect(); } finally { RestoreReceiveTimeout(); } return result; }
/// <summary> /// Получить полное имя файла /// </summary> private string GetFullFileName(Dirs dir, string fileName) { fileName = ScadaUtils.CorrectDirectorySeparator(fileName); string sepPlusFileName = Path.DirectorySeparatorChar + fileName; switch (dir) { case Dirs.Cur: return settings.ArcDir + "Cur" + sepPlusFileName; case Dirs.Hr: return settings.ArcDir + "Hour" + sepPlusFileName; case Dirs.Min: return settings.ArcDir + "Min" + sepPlusFileName; case Dirs.Ev: return settings.ArcDir + "Events" + sepPlusFileName; case Dirs.BaseDAT: return settings.BaseDATDir + fileName; case Dirs.Itf: return settings.ItfDir + fileName; case Dirs.CurCopy: return settings.ArcCopyDir + "Cur" + sepPlusFileName; case Dirs.HrCopy: return settings.ArcCopyDir + "Hour" + sepPlusFileName; case Dirs.MinCopy: return settings.ArcCopyDir + "Min" + sepPlusFileName; default: // Dirs.EvCopy return settings.ArcCopyDir + "Events" + sepPlusFileName; } }