YOUSEFUL / FILEMAKER

YsflFile extensions (v1.0.0)

These functions extend the original 16 file functions, which are documented in FUNCTIONS.md with the YsflFi_ prefix. Unlike the original functions, the ones below return ? message on failure and record the Win32 error code in YsflFi_LastError.

Standard

Function Returns
YsflFi_Register ( {option} ) Registered.
YsflFi_LastError last error code (new functions: Win32 code; original functions: their negative code)
YsflFi_LastErrorText its message

Get / Set selectors added

YsflFi_Get ( selector ; path ) also accepts accessed, hidden, readonly, system, archive, attributes (comma list such as folder,hidden,link), name, stem, extension, parent, isLink, and version:<Field> for executables (version:FileVersion, version:ProductVersion, version:CompanyName, version:ProductName, version:FileDescription).

YsflFi_Set ( selector ; path ; value ) also accepts hidden, readonly, system, archive (value 1 or 0) and accessed (MM/DD/YYYY HH:MM:SS).

Paths and disks

Function Description
YsflFi_PathJoin ( part1 ; part2 {; part3 ; part4} ) joins parts with single backslashes
YsflFi_PathInfo ( path ; selector ) name, stem, extension, parent, drive, absolute, normalized, native (FileMaker path to Windows), filemaker (Windows to filewin: path), exists, isfolder, isfile
YsflFi_SpecialFolder ( name ) desktop, documents, downloads, pictures, appdata, localappdata, programdata, programfiles, temp, home, windows, system
YsflFi_TempPath ( {prefix} {; extension} ) a unique, not yet created path in the temp folder
YsflFi_ListDrives one `letter
YsflFi_DiskInfo ( selector {; drive} ) total, free, used (bytes), label, filesystem, serial; default drive is the Windows drive

Search and content

Function Description
YsflFi_Search ( root ; pattern {; options} ) full paths matching a wildcard pattern; options recursive, depth=N, files, folders
YsflFi_Hash ( path {; algorithm} {; encoding} ) streamed digest: sha256 (default), sha1, sha512, md5, crc32, fnv1a; hex, HEX, base32, base64, safe
YsflFi_Compare ( path1 ; path2 {; mode} ) 1 when identical; mode bytes (default) or hash
YsflFi_IsLocked ( path ) 1 when another process holds the file open without sharing
YsflFi_Trash ( path ) moves a file or folder to the Recycle Bin
YsflFi_Substitute ( path ; find ; replace {; options} ) in-place replace in a UTF-8 text file; returns the count; option i

Containers

Function Description
YsflFi_ReadContainer ( path {; fileName} ) the file as a container (type from the extension)
YsflFi_WriteContainer ( path ; container ) writes a container's bytes; a folder path uses the container's own name
Function Description
YsflFi_CreateLink ( target ; link {; type} ) shortcut (default, a .lnk), symlink (may need Developer Mode or elevation), junction (folders)
YsflFi_ResolveLink ( link ) the target of a shortcut, symlink or junction

Processes, images and watching

Function Description
YsflFi_Exec ( command {; options} ) runs a program hidden and returns its output; options shell (through cmd /c), stderr, timeout=SECONDS (default 60), cwd=PATH; the exit code lands in YsflFi_LastError
YsflFi_ImageInfo ( path ) width¶height¶channels¶format for PNG, JPEG, GIF, BMP
YsflFi_Thumbnail ( source ; maxWidth ; maxHeight {; target} {; options} ) scaled image as a PNG container (or a file when target is given); options square, jpeg, quality=N
YsflFi_WatchStart ( folder {; options} ) starts watching; returns an id; option recursive
YsflFi_WatchPoll ( id ) `action
YsflFi_WatchStop ( id ) stops one watch, or every watch with all