@deephaven/file-explorer 0.22.3-beta.15 → 0.22.3-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/FileUtils.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { ValidationError } from '@deephaven/utils';
2
+
2
3
  /**
3
4
  * A basic list of some common MIME types.
4
5
  */
5
-
6
6
  export var MIME_TYPE;
7
+
7
8
  /**
8
9
  * Collection of utils for operating on file names
9
10
  */
10
-
11
11
  (function (MIME_TYPE) {
12
12
  MIME_TYPE["GROOVY"] = "text/x-groovy";
13
13
  MIME_TYPE["PLAIN_TEXT"] = "text/plain";
@@ -16,7 +16,6 @@ export var MIME_TYPE;
16
16
  MIME_TYPE["SCALA"] = "text/x-scala";
17
17
  MIME_TYPE["UNKNOWN"] = "";
18
18
  })(MIME_TYPE || (MIME_TYPE = {}));
19
-
20
19
  export class FileUtils {
21
20
  /**
22
21
  * Format file extension
@@ -27,65 +26,54 @@ export class FileUtils {
27
26
  var extension = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
28
27
  return extension.length === 0 ? '' : ".".concat(extension);
29
28
  }
29
+
30
30
  /**
31
31
  * Get the depth (how many directories deep it is) of the provided filename with path.
32
32
  * @param name The full file name to get the depth of
33
33
  */
34
-
35
-
36
34
  static getDepth(name) {
37
35
  var _name$match;
38
-
39
36
  if (!FileUtils.hasPath(name)) {
40
37
  throw new Error("Invalid path provided: ".concat(name));
41
38
  }
42
-
43
39
  var matches = (_name$match = name.match(/\//g)) !== null && _name$match !== void 0 ? _name$match : [];
44
40
  return matches.length - 1;
45
41
  }
42
+
46
43
  /**
47
44
  * Get just the extension of file name.
48
45
  * Note that it just returns the last extension, so 'example.tar.gz' would just return 'gz'.
49
46
  * @param name The file name with or without path to get the extension of
50
47
  * @returns The file extension
51
48
  */
52
-
53
-
54
49
  static getExtension(name) {
55
50
  var components = this.getBaseName(name).split('.');
56
-
57
51
  if (components.length > 1) {
58
52
  var _components$pop;
59
-
60
53
  return (_components$pop = components.pop()) !== null && _components$pop !== void 0 ? _components$pop : '';
61
54
  }
62
-
63
55
  return '';
64
56
  }
57
+
65
58
  /**
66
59
  * Get the base name portion of the file, eg '/foo/bar.txt' => 'bar.txt'
67
60
  * @param name The full name including path of the file
68
61
  * @returns Just the file name part of the file
69
62
  */
70
-
71
-
72
63
  static getBaseName(name) {
73
64
  var _name$split$pop;
74
-
75
65
  return (_name$split$pop = name.split('/').pop()) !== null && _name$split$pop !== void 0 ? _name$split$pop : '';
76
66
  }
67
+
77
68
  /**
78
69
  * Create copy file name, used for copying unsaved files so doesn't have to be unique
79
70
  * @param originalName File name
80
71
  * @returns The file name of the copy
81
72
  */
82
-
83
-
84
73
  static getCopyFileName(originalName) {
85
74
  var extensionPosition = originalName.lastIndexOf('.');
86
75
  var extension = null;
87
76
  var name = null;
88
-
89
77
  if (extensionPosition < 0) {
90
78
  // No extension
91
79
  name = originalName;
@@ -93,119 +81,99 @@ export class FileUtils {
93
81
  name = originalName.substring(0, extensionPosition);
94
82
  extension = originalName.substring(extensionPosition + 1);
95
83
  }
96
-
97
84
  var copyName = name ? "".concat(name, "-copy") : 'Copy';
98
85
  return extension !== null ? "".concat(copyName, ".").concat(extension) : copyName;
99
86
  }
87
+
100
88
  /**
101
89
  * Return a MIME type for the provided file
102
90
  * @param name The file name to get the type for
103
91
  * @returns A known MIME type if recognized
104
92
  */
105
-
106
-
107
93
  static getMimeType(name) {
108
94
  var extension = this.getExtension(name).toLowerCase();
109
-
110
95
  switch (extension) {
111
96
  case 'groovy':
112
97
  return MIME_TYPE.GROOVY;
113
-
114
98
  case 'py':
115
99
  return MIME_TYPE.PYTHON;
116
-
117
100
  case 'pyc':
118
101
  return MIME_TYPE.PYTHON_COMPILED;
119
-
120
102
  case 'scala':
121
103
  return MIME_TYPE.SCALA;
122
-
123
104
  case 'txt':
124
105
  return MIME_TYPE.PLAIN_TEXT;
125
-
126
106
  default:
127
107
  return MIME_TYPE.UNKNOWN;
128
108
  }
129
109
  }
110
+
130
111
  /**
131
112
  * Pop the last part of the filename component to return the parent path
132
113
  * @param name The file name to get the parent path of
133
114
  */
134
-
135
-
136
115
  static getParent(name) {
137
116
  if (!FileUtils.hasPath(name)) {
138
117
  throw new Error("Invalid name provided: ".concat(name));
139
118
  }
140
-
141
119
  var parts = name.split('/');
142
-
143
120
  while (parts.pop() === '') {
144
121
  ;
145
122
  }
146
-
147
123
  if (parts.length === 0) {
148
124
  throw new Error("No parent for path provided: ".concat(name));
149
125
  }
150
-
151
126
  return "".concat(parts.join('/'), "/");
152
127
  }
128
+
153
129
  /**
154
130
  * Get the path name portion of the file
155
131
  * @param name The full path with or without filename to get the path of
156
132
  * @returns Just the path with out the file name part, including trailing slash
157
133
  */
158
-
159
-
160
134
  static getPath(name) {
161
135
  if (!FileUtils.hasPath(name)) {
162
136
  throw new Error("Invalid filename provided: ".concat(name));
163
137
  }
164
-
165
138
  var parts = name.split('/');
166
139
  parts.pop();
167
140
  return "".concat(parts.join('/'), "/");
168
141
  }
142
+
169
143
  /**
170
144
  * Check if a given file name includes the full path
171
145
  * @param name The file name to check
172
146
  * @returns True if it's a full path, false otherwise
173
147
  */
174
-
175
-
176
148
  static hasPath(name) {
177
149
  return name.startsWith('/');
178
150
  }
151
+
179
152
  /**
180
153
  * Check a given file name is a path
181
154
  * @param name The file name to check
182
155
  * @returns True if it's a full path, false otherwise
183
156
  */
184
-
185
-
186
157
  static isPath(name) {
187
158
  return name.startsWith('/') && name.endsWith('/');
188
159
  }
160
+
189
161
  /**
190
162
  * Turns a directory file name into a path. Basically ensures there's a trailing slash
191
163
  * @param name The directory name to make a path
192
164
  */
193
-
194
-
195
165
  static makePath(name) {
196
166
  if (!name.endsWith('/')) {
197
167
  return "".concat(name, "/");
198
168
  }
199
-
200
169
  return name;
201
170
  }
171
+
202
172
  /**
203
173
  * Replace extension in the item name
204
174
  * @param name Name to replace the extension in
205
175
  * @param newExtension New extension, defaults to no extension
206
176
  */
207
-
208
-
209
177
  static replaceExtension(name) {
210
178
  var newExtension = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
211
179
  var index = name.lastIndexOf('.');
@@ -213,75 +181,64 @@ export class FileUtils {
213
181
  var extensionString = FileUtils.fileExtensionToString(newExtension);
214
182
  return "".concat(nameWithoutExtension).concat(extensionString);
215
183
  }
184
+
216
185
  /**
217
186
  * Validate the provided name. Throws an error if validation fails
218
187
  * @param name The item name to validate
219
188
  */
220
-
221
-
222
189
  static validateName(name) {
223
190
  // Static checks
224
- var reservedNames = ['.', '..']; // Global flag to show all invalid chars, not just the first match
225
-
191
+ var reservedNames = ['.', '..'];
192
+ // Global flag to show all invalid chars, not just the first match
226
193
  var invalidCharsRegex = /[\\/\0]/g;
227
194
  var invalidCharLabels = new Map([['\0', 'null']]);
228
-
229
195
  if (!name) {
230
196
  throw new ValidationError("Name cannot be empty");
231
197
  }
232
-
233
198
  if (reservedNames.includes(name)) {
234
199
  throw new ValidationError("\"".concat(name, "\" is a reserved name"));
235
200
  }
236
-
237
201
  if (invalidCharsRegex.test(name)) {
238
202
  var _name$match2;
239
-
240
203
  throw new ValidationError("Invalid characters in name: \"".concat(((_name$match2 = name.match(invalidCharsRegex)) !== null && _name$match2 !== void 0 ? _name$match2 : [] // Filter out duplicates
241
204
  ).reduce((acc, next) => acc.includes(next) ? acc : [...acc, next], []).map(char => invalidCharLabels.has(char) ? invalidCharLabels.get(char) : char).join('", "'), "\""));
242
205
  }
243
206
  }
207
+
244
208
  /**
245
209
  * Reduce the provided paths to the minimum selection.
246
210
  * Removes any nested files or directories if a parent is already selected.
247
211
  * @param paths The paths to reduce
248
212
  */
249
-
250
-
251
213
  static reducePaths(paths) {
252
214
  var folders = paths.filter(path => FileUtils.isPath(path));
253
215
  return paths.filter(path => !folders.some(folder => path !== folder && path.startsWith(folder)));
254
216
  }
217
+
255
218
  /**
256
219
  * Removes the root path from the provided file name. Throws if the filename does not start with root.
257
220
  * @param root The root to remove
258
221
  * @param filename Filename to remove the root path from
259
222
  * @returns Filename without the root
260
223
  */
261
-
262
-
263
224
  static removeRoot(root, filename) {
264
225
  if (root.length === 0) {
265
226
  return filename;
266
227
  }
267
-
268
228
  if (!filename.startsWith(root)) {
269
229
  throw new Error("Filename ".concat(filename, " does not start with expected root ").concat(root));
270
230
  }
271
-
272
231
  return filename.substring(root.length);
273
232
  }
233
+
274
234
  /**
275
235
  * Add root to the filename as prefix
276
236
  * @param path Filename to prefix root to
277
237
  * @returns Filename with root at the prefix
278
238
  */
279
-
280
-
281
239
  static addRoot(root, path) {
282
240
  return "".concat(root).concat(path);
283
241
  }
284
-
285
242
  }
286
243
  export default FileUtils;
287
244
  //# sourceMappingURL=FileUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUtils.js","names":["ValidationError","MIME_TYPE","FileUtils","fileExtensionToString","extension","length","getDepth","name","hasPath","Error","matches","match","getExtension","components","getBaseName","split","pop","getCopyFileName","originalName","extensionPosition","lastIndexOf","substring","copyName","getMimeType","toLowerCase","GROOVY","PYTHON","PYTHON_COMPILED","SCALA","PLAIN_TEXT","UNKNOWN","getParent","parts","join","getPath","startsWith","isPath","endsWith","makePath","replaceExtension","newExtension","index","nameWithoutExtension","extensionString","validateName","reservedNames","invalidCharsRegex","invalidCharLabels","Map","includes","test","reduce","acc","next","map","char","has","get","reducePaths","paths","folders","filter","path","some","folder","removeRoot","root","filename","addRoot"],"sources":["../src/FileUtils.ts"],"sourcesContent":["import { ValidationError } from '@deephaven/utils';\n\n/**\n * A basic list of some common MIME types.\n */\nexport enum MIME_TYPE {\n GROOVY = 'text/x-groovy',\n PLAIN_TEXT = 'text/plain',\n PYTHON = 'text/x-python',\n PYTHON_COMPILED = 'application/x-python-code',\n SCALA = 'text/x-scala',\n UNKNOWN = '',\n}\n\n/**\n * Collection of utils for operating on file names\n */\nexport class FileUtils {\n /**\n * Format file extension\n * @param extension File extension to format, defaults to empty string\n * @returns Formatted string - '' for no extension, '.' for empty extension, '.ext' for non-empty extension\n */\n static fileExtensionToString(extension = ''): string {\n return extension.length === 0 ? '' : `.${extension}`;\n }\n\n /**\n * Get the depth (how many directories deep it is) of the provided filename with path.\n * @param name The full file name to get the depth of\n */\n static getDepth(name: string): number {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid path provided: ${name}`);\n }\n const matches = name.match(/\\//g) ?? [];\n return matches.length - 1;\n }\n\n /**\n * Get just the extension of file name.\n * Note that it just returns the last extension, so 'example.tar.gz' would just return 'gz'.\n * @param name The file name with or without path to get the extension of\n * @returns The file extension\n */\n static getExtension(name: string): string {\n const components = this.getBaseName(name).split('.');\n if (components.length > 1) {\n return components.pop() ?? '';\n }\n return '';\n }\n\n /**\n * Get the base name portion of the file, eg '/foo/bar.txt' => 'bar.txt'\n * @param name The full name including path of the file\n * @returns Just the file name part of the file\n */\n static getBaseName(name: string): string {\n return name.split('/').pop() ?? '';\n }\n\n /**\n * Create copy file name, used for copying unsaved files so doesn't have to be unique\n * @param originalName File name\n * @returns The file name of the copy\n */\n static getCopyFileName(originalName: string): string {\n const extensionPosition = originalName.lastIndexOf('.');\n let extension = null;\n let name = null;\n if (extensionPosition < 0) {\n // No extension\n name = originalName;\n } else {\n name = originalName.substring(0, extensionPosition);\n extension = originalName.substring(extensionPosition + 1);\n }\n const copyName = name ? `${name}-copy` : 'Copy';\n return extension !== null ? `${copyName}.${extension}` : copyName;\n }\n\n /**\n * Return a MIME type for the provided file\n * @param name The file name to get the type for\n * @returns A known MIME type if recognized\n */\n static getMimeType(name: string): MIME_TYPE {\n const extension = this.getExtension(name).toLowerCase();\n switch (extension) {\n case 'groovy':\n return MIME_TYPE.GROOVY;\n case 'py':\n return MIME_TYPE.PYTHON;\n case 'pyc':\n return MIME_TYPE.PYTHON_COMPILED;\n case 'scala':\n return MIME_TYPE.SCALA;\n case 'txt':\n return MIME_TYPE.PLAIN_TEXT;\n default:\n return MIME_TYPE.UNKNOWN;\n }\n }\n\n /**\n * Pop the last part of the filename component to return the parent path\n * @param name The file name to get the parent path of\n */\n static getParent(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid name provided: ${name}`);\n }\n\n const parts = name.split('/');\n while (parts.pop() === '');\n if (parts.length === 0) {\n throw new Error(`No parent for path provided: ${name}`);\n }\n return `${parts.join('/')}/`;\n }\n\n /**\n * Get the path name portion of the file\n * @param name The full path with or without filename to get the path of\n * @returns Just the path with out the file name part, including trailing slash\n */\n static getPath(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid filename provided: ${name}`);\n }\n const parts = name.split('/');\n parts.pop();\n return `${parts.join('/')}/`;\n }\n\n /**\n * Check if a given file name includes the full path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static hasPath(name: string): boolean {\n return name.startsWith('/');\n }\n\n /**\n * Check a given file name is a path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static isPath(name: string): boolean {\n return name.startsWith('/') && name.endsWith('/');\n }\n\n /**\n * Turns a directory file name into a path. Basically ensures there's a trailing slash\n * @param name The directory name to make a path\n */\n static makePath(name: string): string {\n if (!name.endsWith('/')) {\n return `${name}/`;\n }\n return name;\n }\n\n /**\n * Replace extension in the item name\n * @param name Name to replace the extension in\n * @param newExtension New extension, defaults to no extension\n */\n static replaceExtension(name: string, newExtension = ''): string {\n const index = name.lastIndexOf('.');\n const nameWithoutExtension = index > -1 ? name.substring(0, index) : name;\n const extensionString = FileUtils.fileExtensionToString(newExtension);\n return `${nameWithoutExtension}${extensionString}`;\n }\n\n /**\n * Validate the provided name. Throws an error if validation fails\n * @param name The item name to validate\n */\n static validateName(name: string): void {\n // Static checks\n const reservedNames = ['.', '..'];\n // Global flag to show all invalid chars, not just the first match\n const invalidCharsRegex = /[\\\\/\\0]/g;\n const invalidCharLabels = new Map([['\\0', 'null']]);\n\n if (!name) {\n throw new ValidationError(`Name cannot be empty`);\n }\n if (reservedNames.includes(name)) {\n throw new ValidationError(`\"${name}\" is a reserved name`);\n }\n if (invalidCharsRegex.test(name)) {\n throw new ValidationError(\n `Invalid characters in name: \"${(name.match(invalidCharsRegex) ?? [])\n // Filter out duplicates\n .reduce(\n (acc, next) => (acc.includes(next) ? acc : [...acc, next]),\n [] as string[]\n )\n .map(char =>\n invalidCharLabels.has(char) ? invalidCharLabels.get(char) : char\n )\n .join('\", \"')}\"`\n );\n }\n }\n\n /**\n * Reduce the provided paths to the minimum selection.\n * Removes any nested files or directories if a parent is already selected.\n * @param paths The paths to reduce\n */\n static reducePaths(paths: string[]): string[] {\n const folders = paths.filter(path => FileUtils.isPath(path));\n return paths.filter(\n path =>\n !folders.some(folder => path !== folder && path.startsWith(folder))\n );\n }\n\n /**\n * Removes the root path from the provided file name. Throws if the filename does not start with root.\n * @param root The root to remove\n * @param filename Filename to remove the root path from\n * @returns Filename without the root\n */\n static removeRoot(root: string, filename: string): string {\n if (root.length === 0) {\n return filename;\n }\n if (!filename.startsWith(root)) {\n throw new Error(\n `Filename ${filename} does not start with expected root ${root}`\n );\n }\n\n return filename.substring(root.length);\n }\n\n /**\n * Add root to the filename as prefix\n * @param path Filename to prefix root to\n * @returns Filename with root at the prefix\n */\n static addRoot(root: string, path: string): string {\n return `${root}${path}`;\n }\n}\n\nexport default FileUtils;\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,kBAAhC;AAEA;AACA;AACA;;AACA,WAAYC,SAAZ;AASA;AACA;AACA;;WAXYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAYZ,OAAO,MAAMC,SAAN,CAAgB;EACrB;AACF;AACA;AACA;AACA;EAC8B,OAArBC,qBAAqB,GAAyB;IAAA,IAAxBC,SAAwB,uEAAZ,EAAY;IACnD,OAAOA,SAAS,CAACC,MAAV,KAAqB,CAArB,GAAyB,EAAzB,cAAkCD,SAAlC,CAAP;EACD;EAED;AACF;AACA;AACA;;;EACiB,OAARE,QAAQ,CAACC,IAAD,E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,EAAyC;IACxD,IAAID,IAAI,CAAC7D,MAAL,KAAgB,CAApB,EAAuB;MACrB,OAAO8D,QAAP;IACD;;IACD,IAAI,CAACA,QAAQ,CAAChC,UAAT,CAAoB+B,IAApB,CAAL,EAAgC;MAC9B,MAAM,IAAIzD,KAAJ,oBACQ0D,QADR,gDACsDD,IADtD,EAAN;IAGD;;IAED,OAAOC,QAAQ,CAAC9C,SAAT,CAAmB6C,IAAI,CAAC7D,MAAxB,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACgB,OAAP+D,OAAO,CAACF,IAAD,EAAeJ,IAAf,EAAqC;IACjD,iBAAUI,IAAV,SAAiBJ,IAAjB;EACD;;AAxOoB;AA2OvB,eAAe5D,SAAf"}
1
+ {"version":3,"file":"FileUtils.js","names":["ValidationError","MIME_TYPE","FileUtils","fileExtensionToString","extension","length","getDepth","name","hasPath","Error","matches","match","getExtension","components","getBaseName","split","pop","getCopyFileName","originalName","extensionPosition","lastIndexOf","substring","copyName","getMimeType","toLowerCase","GROOVY","PYTHON","PYTHON_COMPILED","SCALA","PLAIN_TEXT","UNKNOWN","getParent","parts","join","getPath","startsWith","isPath","endsWith","makePath","replaceExtension","newExtension","index","nameWithoutExtension","extensionString","validateName","reservedNames","invalidCharsRegex","invalidCharLabels","Map","includes","test","reduce","acc","next","map","char","has","get","reducePaths","paths","folders","filter","path","some","folder","removeRoot","root","filename","addRoot"],"sources":["../src/FileUtils.ts"],"sourcesContent":["import { ValidationError } from '@deephaven/utils';\n\n/**\n * A basic list of some common MIME types.\n */\nexport enum MIME_TYPE {\n GROOVY = 'text/x-groovy',\n PLAIN_TEXT = 'text/plain',\n PYTHON = 'text/x-python',\n PYTHON_COMPILED = 'application/x-python-code',\n SCALA = 'text/x-scala',\n UNKNOWN = '',\n}\n\n/**\n * Collection of utils for operating on file names\n */\nexport class FileUtils {\n /**\n * Format file extension\n * @param extension File extension to format, defaults to empty string\n * @returns Formatted string - '' for no extension, '.' for empty extension, '.ext' for non-empty extension\n */\n static fileExtensionToString(extension = ''): string {\n return extension.length === 0 ? '' : `.${extension}`;\n }\n\n /**\n * Get the depth (how many directories deep it is) of the provided filename with path.\n * @param name The full file name to get the depth of\n */\n static getDepth(name: string): number {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid path provided: ${name}`);\n }\n const matches = name.match(/\\//g) ?? [];\n return matches.length - 1;\n }\n\n /**\n * Get just the extension of file name.\n * Note that it just returns the last extension, so 'example.tar.gz' would just return 'gz'.\n * @param name The file name with or without path to get the extension of\n * @returns The file extension\n */\n static getExtension(name: string): string {\n const components = this.getBaseName(name).split('.');\n if (components.length > 1) {\n return components.pop() ?? '';\n }\n return '';\n }\n\n /**\n * Get the base name portion of the file, eg '/foo/bar.txt' => 'bar.txt'\n * @param name The full name including path of the file\n * @returns Just the file name part of the file\n */\n static getBaseName(name: string): string {\n return name.split('/').pop() ?? '';\n }\n\n /**\n * Create copy file name, used for copying unsaved files so doesn't have to be unique\n * @param originalName File name\n * @returns The file name of the copy\n */\n static getCopyFileName(originalName: string): string {\n const extensionPosition = originalName.lastIndexOf('.');\n let extension = null;\n let name = null;\n if (extensionPosition < 0) {\n // No extension\n name = originalName;\n } else {\n name = originalName.substring(0, extensionPosition);\n extension = originalName.substring(extensionPosition + 1);\n }\n const copyName = name ? `${name}-copy` : 'Copy';\n return extension !== null ? `${copyName}.${extension}` : copyName;\n }\n\n /**\n * Return a MIME type for the provided file\n * @param name The file name to get the type for\n * @returns A known MIME type if recognized\n */\n static getMimeType(name: string): MIME_TYPE {\n const extension = this.getExtension(name).toLowerCase();\n switch (extension) {\n case 'groovy':\n return MIME_TYPE.GROOVY;\n case 'py':\n return MIME_TYPE.PYTHON;\n case 'pyc':\n return MIME_TYPE.PYTHON_COMPILED;\n case 'scala':\n return MIME_TYPE.SCALA;\n case 'txt':\n return MIME_TYPE.PLAIN_TEXT;\n default:\n return MIME_TYPE.UNKNOWN;\n }\n }\n\n /**\n * Pop the last part of the filename component to return the parent path\n * @param name The file name to get the parent path of\n */\n static getParent(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid name provided: ${name}`);\n }\n\n const parts = name.split('/');\n while (parts.pop() === '');\n if (parts.length === 0) {\n throw new Error(`No parent for path provided: ${name}`);\n }\n return `${parts.join('/')}/`;\n }\n\n /**\n * Get the path name portion of the file\n * @param name The full path with or without filename to get the path of\n * @returns Just the path with out the file name part, including trailing slash\n */\n static getPath(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid filename provided: ${name}`);\n }\n const parts = name.split('/');\n parts.pop();\n return `${parts.join('/')}/`;\n }\n\n /**\n * Check if a given file name includes the full path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static hasPath(name: string): boolean {\n return name.startsWith('/');\n }\n\n /**\n * Check a given file name is a path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static isPath(name: string): boolean {\n return name.startsWith('/') && name.endsWith('/');\n }\n\n /**\n * Turns a directory file name into a path. Basically ensures there's a trailing slash\n * @param name The directory name to make a path\n */\n static makePath(name: string): string {\n if (!name.endsWith('/')) {\n return `${name}/`;\n }\n return name;\n }\n\n /**\n * Replace extension in the item name\n * @param name Name to replace the extension in\n * @param newExtension New extension, defaults to no extension\n */\n static replaceExtension(name: string, newExtension = ''): string {\n const index = name.lastIndexOf('.');\n const nameWithoutExtension = index > -1 ? name.substring(0, index) : name;\n const extensionString = FileUtils.fileExtensionToString(newExtension);\n return `${nameWithoutExtension}${extensionString}`;\n }\n\n /**\n * Validate the provided name. Throws an error if validation fails\n * @param name The item name to validate\n */\n static validateName(name: string): void {\n // Static checks\n const reservedNames = ['.', '..'];\n // Global flag to show all invalid chars, not just the first match\n const invalidCharsRegex = /[\\\\/\\0]/g;\n const invalidCharLabels = new Map([['\\0', 'null']]);\n\n if (!name) {\n throw new ValidationError(`Name cannot be empty`);\n }\n if (reservedNames.includes(name)) {\n throw new ValidationError(`\"${name}\" is a reserved name`);\n }\n if (invalidCharsRegex.test(name)) {\n throw new ValidationError(\n `Invalid characters in name: \"${(name.match(invalidCharsRegex) ?? [])\n // Filter out duplicates\n .reduce(\n (acc, next) => (acc.includes(next) ? acc : [...acc, next]),\n [] as string[]\n )\n .map(char =>\n invalidCharLabels.has(char) ? invalidCharLabels.get(char) : char\n )\n .join('\", \"')}\"`\n );\n }\n }\n\n /**\n * Reduce the provided paths to the minimum selection.\n * Removes any nested files or directories if a parent is already selected.\n * @param paths The paths to reduce\n */\n static reducePaths(paths: string[]): string[] {\n const folders = paths.filter(path => FileUtils.isPath(path));\n return paths.filter(\n path =>\n !folders.some(folder => path !== folder && path.startsWith(folder))\n );\n }\n\n /**\n * Removes the root path from the provided file name. Throws if the filename does not start with root.\n * @param root The root to remove\n * @param filename Filename to remove the root path from\n * @returns Filename without the root\n */\n static removeRoot(root: string, filename: string): string {\n if (root.length === 0) {\n return filename;\n }\n if (!filename.startsWith(root)) {\n throw new Error(\n `Filename ${filename} does not start with expected root ${root}`\n );\n }\n\n return filename.substring(root.length);\n }\n\n /**\n * Add root to the filename as prefix\n * @param path Filename to prefix root to\n * @returns Filename with root at the prefix\n */\n static addRoot(root: string, path: string): string {\n return `${root}${path}`;\n }\n}\n\nexport default FileUtils;\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kBAAkB;;AAElD;AACA;AACA;AACA,WAAYC,SAAS;;AASrB;AACA;AACA;AAFA,WATYA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAATA,SAAS;AAAA,GAATA,SAAS,KAATA,SAAS;AAYrB,OAAO,MAAMC,SAAS,CAAC;EACrB;AACF;AACA;AACA;AACA;EACE,OAAOC,qBAAqB,GAAyB;IAAA,IAAxBC,SAAS,uEAAG,EAAE;IACzC,OAAOA,SAAS,CAACC,MAAM,KAAK,CAAC,GAAG,EAAE,cAAOD,SAAS,CAAE;EACtD;;EAEA;AACF;AACA;AACA;EACE,OAAOE,QAAQ,CA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