import { type FileStorage } from './FileStorage'; /** * A basic list of some common MIME types. */ export declare enum MIME_TYPE { GROOVY = "text/x-groovy", PLAIN_TEXT = "text/plain", PYTHON = "text/x-python", PYTHON_COMPILED = "application/x-python-code", SCALA = "text/x-scala", UNKNOWN = "" } /** * Collection of utils for operating on file names */ export declare class FileUtils { static fileExists(fileStorage: FileStorage, name: string): Promise; /** * Format file extension * @param extension File extension to format, defaults to empty string * @returns Formatted string - '' for no extension, '.' for empty extension, '.ext' for non-empty extension */ static fileExtensionToString(extension?: string): string; /** * Get the depth (how many directories deep it is) of the provided filename with path. * @param name The full file name to get the depth of */ static getDepth(name: string): number; /** * Get just the extension of file name. * Note that it just returns the last extension, so 'example.tar.gz' would just return 'gz'. * @param name The file name with or without path to get the extension of * @returns The file extension */ static getExtension(name: string): string; /** * Get the base name portion of the file, eg '/foo/bar.txt' => 'bar.txt' * @param name The full name including path of the file * @returns Just the file name part of the file */ static getBaseName(name: string): string; /** * Create copy file name, used for copying unsaved files so doesn't have to be unique * @param originalName File name * @returns The file name of the copy */ static getCopyFileName(originalName: string): string; static getUniqueCopyFileName(fileStorage: FileStorage, originalName: string): Promise; /** * Return a MIME type for the provided file * @param name The file name to get the type for * @returns A known MIME type if recognized */ static getMimeType(name: string): MIME_TYPE; /** * Pop the last part of the filename component to return the parent path * @param name The file name to get the parent path of */ static getParent(name: string): string; /** * Get the path name portion of the file * @param name The full path with or without filename to get the path of * @returns Just the path with out the file name part, including trailing slash */ static getPath(name: string): string; /** * Check if a given file name includes the full path * @param name The file name to check * @returns True if it's a full path, false otherwise */ static hasPath(name: string): boolean; /** * Check a given file name is a path * @param name The file name to check * @returns True if it's a full path, false otherwise */ static isPath(name: string): boolean; /** * Turns a directory file name into a path. Basically ensures there's a trailing slash * @param name The directory name to make a path */ static makePath(name: string): string; /** * Replace extension in the item name * @param name Name to replace the extension in * @param newExtension New extension, defaults to no extension */ static replaceExtension(name: string, newExtension?: string): string; /** * Validate the provided name. Throws an error if validation fails * @param name The item name to validate */ static validateName(name: string): void; /** * Reduce the provided paths to the minimum selection. * Removes any nested files or directories if a parent is already selected. * @param paths The paths to reduce */ static reducePaths(paths: string[]): string[]; /** * Removes the root path from the provided file name. Throws if the filename does not start with root. * @param root The root to remove * @param filename Filename to remove the root path from * @returns Filename without the root */ static removeRoot(root: string, filename: string): string; /** * Add root to the filename as prefix * @param path Filename to prefix root to * @returns Filename with root at the prefix */ static addRoot(root: string, path: string): string; } export default FileUtils; //# sourceMappingURL=FileUtils.d.ts.map