NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Common.IO.DirectoryCommand Class Reference

Static Public Member Functions

static string CreateRecursiveFromFile (string file)
 

Static Private Member Functions

static string CreateRecursive (string path)
 

Static Private Attributes

static readonly object Locker = new object()
 

Detailed Description

Definition at line 28 of file DirectoryCommand.cs.

Member Function Documentation

static string Ntp.Common.IO.DirectoryCommand.CreateRecursive ( string  path)
inlinestaticprivate

Definition at line 45 of file DirectoryCommand.cs.

References s().

46  {
47  // Make it thread safe
48  lock (Locker)
49  {
50  string fullPath = path.Trim();
51  string lastPath;
52 
53  // Trim
54  do
55  {
56  lastPath = fullPath;
57  fullPath = fullPath.TrimEnd().
58  TrimEnd(Path.DirectorySeparatorChar).
59  TrimEnd(Path.AltDirectorySeparatorChar);
60  } while (lastPath != fullPath);
61 
62  if (fullPath.Length <= 1)
63  return null;
64 
65  // Find components
66  string created = null;
67  char[] s = {Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar};
68  var elements = fullPath.Split(s, StringSplitOptions.RemoveEmptyEntries).ToList();
69 
70  if (elements.Count <= 1)
71  return null;
72 
73  // Find root
74  string currentPath = elements[0];
75  elements.RemoveAt(0);
76 
77  // Adjust Unix paths
78  if (path.Trim()[0] == Path.DirectorySeparatorChar || path.Trim()[0] == Path.AltDirectorySeparatorChar)
79  currentPath = Path.DirectorySeparatorChar + currentPath;
80 
81  // Create it
82  foreach (string element in elements)
83  {
84  currentPath = $"{currentPath}{Path.DirectorySeparatorChar}{element}";
85  if (Directory.Exists(currentPath))
86  continue;
87 
88  Directory.CreateDirectory(currentPath);
89  created = currentPath;
90  }
91 
92  return created;
93  }
94  }
static readonly object Locker
function s(a)
Definition: jquery.min.js:2

Here is the call graph for this function:

static string Ntp.Common.IO.DirectoryCommand.CreateRecursiveFromFile ( string  file)
inlinestatic

Definition at line 32 of file DirectoryCommand.cs.

Referenced by Ntp.Analyzer.Export.FileSystemDestination.PrepareFile().

33  {
34  int pos1 = file.LastIndexOf(Path.DirectorySeparatorChar);
35  int pos2 = file.LastIndexOf(Path.AltDirectorySeparatorChar);
36 
37  int pos = pos1 > pos2 ? pos1 : pos2;
38  if (pos == -1)
39  return null;
40 
41  string path = file.Substring(0, pos);
42  return CreateRecursive(path);
43  }
static string CreateRecursive(string path)

Here is the caller graph for this function:

Member Data Documentation

readonly object Ntp.Common.IO.DirectoryCommand.Locker = new object()
staticprivate

Definition at line 30 of file DirectoryCommand.cs.


The documentation for this class was generated from the following file: