import * as path from 'path-browserify'; import { IFilePath } from './FrontApplet/FileSystem/types'; /** * `fpath` utility mirrors node [path](https://nodejs.org/docs/latest/api/path.html) * module, but accepts IFilePath type instead of strings. It is useful when * working with [sos.fileSystem](/sdk/sos/fileSystem). * * :::info Not implemented functions: * - `format()` * - `matchesGlob()` * - `parse()` * - `relative()` * ::: * * @position 99 * * @example * import { sos, fpath } from "@signageos/front-applet"; * * const [internal] = await sos.fileSystem.listInternalStorageUnits(); * const rootPath = { * filePath: '', // Empty string is used as an absolute path instead of "/" * storageUnit: internal * }; * * // list saved files in videos/2025-05-19/ directory * const videos = await sos.fileSystem.listFiles( * fpath.join(rootPath, "videos", "2025-05-19"), * ); */ export declare const fpath: { /** * Return the last portion of path, since it is not a valid path, a string is returned. * * @param filePath The file path to extract the base name from. * @param suffix An optional suffix to remove from the result. * @return {string} The last portion of path, with suffix removed if it is provided and present in the path. * * @example * const path = { filePath: "images/picture.png", storageUnit: ... }; * fpath.basename(path); // "picture.png" */ basename(filePath: IFilePath, suffix?: string): string; /** * Removes the last portion of path, returning the parent directory of the path. Ignores trailing slashes * * @param filePath The file path to get the directory from. * @return {IFilePath} The parent directory of the path, with the same storage unit. * * @example * const path = { filePath: "images/picture.png", storageUnit: ... }; * fpath.dirname(path); // { filePath: "images", storageUnit: ... } */ dirname(filePath: IFilePath): IFilePath; /** * Returns extension of the path, from the last period, including the period. * * @param filePath The file path to extract the extension from. * @return {string} The extension of the path, from the last period, including the period. * * @example * const path = { filePath: "images/picture.png", storageUnit: ... }; * fpath.dirname(path); // .png */ extname(filePath: IFilePath): string; /** * Always returns true, because all file paths are absolute * * @param _ The file path to check. */ isAbsolute(_: IFilePath): boolean; /** * Returns new filePath with paths appended to it and normalized (resolved . and ..) * * @param filePath The base file path. * @param paths Path segments to append. * @return {IFilePath} New file path with paths appended to it and normalized. * * @example * const path = { filePath: "images", storageUnit: ... }; * fpath.join(path, "racoons", ".", "picture.png"); // { filePath: "images/racoons/picture.png", storageUnit: ... } */ join(filePath: IFilePath, ...paths: string[]): IFilePath; /** * Similar to `fpath.join()`, but resulting path will always be subdirectory of base. * * @param base The base file path that the result will always be a subdirectory of. * @param paths Path segments to append. * @return {IFilePath} New file path with paths appended to it, normalized and guaranteed to be a subdirectory of base. * * @example * const path = { filePath: "uploads/userA", storageUnit: ... }; * fpath.safeJoin(path, "..", "userB", "picture.png"); // { filePath: "uploads/userA/userB/picture.png", storageUnit: ... } */ safeJoin(base: IFilePath, ...paths: string[]): IFilePath; /** * Resolves `.` and `..` in the path and removes multiple slashes. * * @param filePath The file path to normalize. * @returns {IFilePath} Normalized file path. * * @example * const path = { filePath: "images//test/../test2/./", storageUnit: ... }; * fpath.normalize(path); // { filePath: "images/test2/", storageUnit: ... } */ normalize(filePath: IFilePath): IFilePath; /** * Works like `fpath.join()`, but if any of the paths is an absolute path, it will be resolved to the root of the storage unit instead of the root of the file system. * * @param filePath The base file path. * @param paths Path segments to resolve. * @return {IFilePath} New file path with paths resolved to it. */ resolve(filePath: IFilePath, ...paths: string[]): IFilePath; /** * Separator used for joining path segments */ sep: string; /** * Concatenate filePath with paths without adding separator. * * @param filePath The file path to concatenate to. * @param paths Strings to concatenate. * @return {IFilePath} New file path with paths concatenated to it. * * @example * const path = { filePath: "uploads/archive.tar", storageUnit: ... }; * fpath.concat(path, "_extracted"); // { filePath: "uploads/archive.tar_extracted", storageUnit: ... } */ concat(filePath: IFilePath, ...paths: string[]): IFilePath; /** * Convert filePath to string, this string is not guaranteed to be unique and should be only used for debugging/logging. * * @param filePath The file path to convert to string. * @return {string} The string representation of the file path. */ stringify(filePath: IFilePath): string; /** * Underlying path polyfill */ path: path.Path; };