export class FileUtils { public static formatFileSize(bytes: number): string { if (bytes < 1024) { return `${bytes} Bytes`; } else if (bytes < 1024 * 1024) { return `${(bytes / 1024).toFixed(2)} KB`; } else { return `${(bytes / (1024 * 1024)).toFixed(2)} MB`; } } public static getFileName(fileFullPath: string): string | null { const lastSlashIndex = fileFullPath.lastIndexOf('\\'); if (lastSlashIndex === -1 || lastSlashIndex === 0 || lastSlashIndex === fileFullPath.length - 1) { return fileFullPath; // No folder found } return fileFullPath.slice(lastSlashIndex + 1); } public static getFileExt(filename: string): string | null { const lastDotIndex = filename.lastIndexOf('.'); if (lastDotIndex === -1 || lastDotIndex === 0 || lastDotIndex === filename.length - 1) { return null; // No extension found } return filename.slice(lastDotIndex); } }