Sapphire Documentation

Sapphire\File\File

class File


public function __construct(string $path) - Constructs class with provided path

public static function IsTravellerFolder(string $file_name): bool - Checks if folder is . or ..

public function Exists(): bool - Returns if file exists

public function Read(): string | null - Reads file

public function Write(string $buffer) - Write file with buffer

public function Json(stdClass|array|null $buffer = null): stdClass | null - Read or write json buffer to file

public function GetExtension(): string - Returns file extension

public function GetMimeType(): string - Returns mime type of file

public function Include(array $data = []) - Include file to php

public function Out(): void - Outputs file and set response header to mime type

public function Type(): string - Returns file type

public function Files(): array - Returns all files inside

public function NotSecretFiles(): array - Returns all files that have not "~" prefix in filename as string-path-files

public function SecretFiles(): array - Returns all files that have "~" prefix in filename  as string-path-files

public function FilesProceed(): array - Returns all files in folder  as File class Instance

public function NotSecretFilesProceed(): array - Returns all files that have not "~" prefix in filename as File class Instance

public function SecretFilesProceed(): array - Returns all files that have "~" prefix in filename  as File class Instance

public function Move(string $new_path): void - Moves file to new path

public function MoveUploaded(string $new_path): void - Moves the uploaded file

public function Delete(): void - Deletes file

public function GetPath(): string - Returns file path

public function GetFilename(): string - Returns filename (not whole path)

public function IsOnyx(): bool - Checks if file is onyx

public function Clone(string $location): void - Clones file to new location

public function CreateFolder(): void - Mkdir at provided path

public function GetChild(string $filename): File - Gets the file child


public static function Extension(string $path): string - Returns file $path extension

public static function GenerateTemporary(string $extension): string - Returns temp file path

public static function MoveUploadedFile(string $from, string $to): void - Move uploaded files from: $from to: $to path

public static function RenameFile(string $from, string $to): void - Renames file

public static function MoveFile(string $from, string $to): void - Moves file from $from to $to path

public static function DeleteFile(string $file): void - Deletes file in path $path

public static function Filename(string $path): string - Returns filename from path

public static function CloneFile(string $a, string $b): void - Clones file a to file b

public static function CreateNewFolder(string $path): void - Creates new folder

public static function GetFolderSize(string $path): int - Returns size of folder


public static $Image = "Image"

public static $Audio = "Audio"

public static $Video = "Video"

public static $Script = "Script"

public static $Style = "Style"

public static $Text = "Text"

public static $Other = "Other"