Skip to content
Brom Bresenham edited this page Nov 9, 2023 · 14 revisions

File.rogue

class File [compound]

Global Methods

Signature Return Type Description
create( filepath:String ) File
operator+( left:File, right:File ) File
operator+( left:File, right:String ) File
operator+( left:String, right:File ) File

Properties

Name Type Description
filepath String

Methods

Signature Return Type Description
abs() File
character_writer() CharacterToUTF8ByteWriter
contains_wildcards() Logical
conventional_filepath() String
crc32() Int32
create_folder() Logical Creates the specified folder along with intermediate folders if necessary. Returns 'true' on success or if the filepath already exists as a folder. Returns 'false' on failure to
delete() Logical
description() String
esc() String
exists() Logical
extension() String
filename() String
filepath_before_wildcards() String Example: alpha/beta/image*.png -> alpha/beta
folder() String
folder_before_wildcards() String Example: alpha/beta/image*.png -> alpha/beta
has_parent() Logical
is_absolute() Logical
is_folder() Logical
is_hidden() Logical
is_valid_utf8() Logical
reader() FileReader
resolved() File
separator() Character
size() Int64
split_filepath_and_extension() (filepath:String,extension:String)
timestamp_ms() Int64 Returns the last modified time.
to<>() Boxed<<File>>
to<>() String
without_extension() File
without_trailing_separator() File Removes trailing slash on anything except "/"
appending( suffix:String ) File "filename.png".appending("@2x") -> "filename@2x.png" "filename.png".appending(null) -> "filename.png"
common_folder( other:File ) File
contains( pattern:FilePattern ) Logical Returns true if this folder contains a file with the given pattern.
copy_to( destination:File, &if_different, &if_newer, &dry_run, &verbose, &ignore_hidden ) Int32? Copies a file or the contents of a folder to a specified file or folder. Returns the count of files copied or null on an error.
is_newer_than( other:File ) Logical
is_valid_filename_character( ch:Character, &any_os ) Logical
listing( filepattern:FilePattern?, &ignore_hidden, &absolute, &omit_path, &files, &folders, &unsorted, &recursive ) String[] Use the filepattern '**' for a recursive listing.
listing( pattern:String, &ignore_hidden, &absolute, &omit_path, &files, &folders, &unsorted, &recursive ) String[]
load_as_bytes( &discard_bom ) Byte[] discard_bom
  Discard the Byte Order Marker, if it exists.
load_as_string( [encoding=StringEncoding.AUTODETECT:StringEncoding] ) String
operator/( other:File ) File
operator/( other_filepath:String ) File
operator/( pattern:FilePattern ) File
operator==( other:File ) Logical Returns true if 'this' and 'other' both exist, are the same size, and have the same CRC32.
parent( [level=1:Int32] ) File
print_writer( &append ) PrintWriter
relative_to( base_folder:File ) File
rename( destination:File ) Logical
save( data:Byte[] ) Logical
save( data:String, &bom ) Logical
symlink( target:File ) Symlinks this File to the target file. Unix-style example: File("/usr/local/bin/cmdlauncher").symlink(File("/opt/myapp/bin/cmd"))
with_destination( destination:File ) File Uses console-style filename and folder rules to modify a source filepath given a destination filepath.

File( "folder1/filename1" ).with_destination( File("folder2/filename2") ) -> "folder2/filename2" File( "folder1/filename1" ).with_destination( File("folder2") ) -> "folder2/filename1" File( "folder1/filename1" ).with_destination( File("filename2") ) -> "filename2" File( "filename1" ).with_destination( File("folder2/filename2") ) -> "folder2/filename2" File( "filename1" ).with_destination( File("folder2") ) -> "folder2/filename1" File( "filename1" ).with_destination( File("filename2") ) -> "filename2" File( "folder1" ).with_destination( File("folder2/filename2") ) -> "folder2/filename2" File( "folder1" ).with_destination( File("folder2") ) -> "folder2/folder1" File( "folder1" ).with_destination( File("filename2") ) -> "filename2" (folder1 renamed to filename2)

Definitions - path: .exists and .is_folder - filename: not .exists or (.exists and not .is_folder)
with_extension( ext:String ) File if ext is null or "":
  Removes any current ".extension".
else
  Removes any current ".extension" and adds ".$"(ext).
writer( &append ) FileWriter

FileDescriptorIO.rogue

class FDReader

extends Object

incorporates Reader<<$DataType>>

Global Methods

Signature Return Type Description
stderr() FDReader
stdin() FDReader

Properties

Name Type Description
auto_close Logical
buffer_position Int32
buffer Byte[]
fd Int32
position Int32

Methods

Signature Return Type Description
init( fd:Int32, [auto_close=true:Logical] )
buffer_more() Logical Used by Process which needs to keep buffering from both the stdout and stderr of a process to make sure the process doesn't get blocked.
close()
has_another() Logical
is_open() Logical
on_cleanup()
on_end_use()
on_use() FDReader
peek() Byte
position() Int32
read() Byte
reset()
to<>() Byte[]
to<>() String
read( buffer:Byte[], limit:Int32 ) Int32
seek( pos:Int32 )
skip( n:Int32 )

class FDWriter

extends Object

incorporates Writer<<$DataType>>

Global Methods

Signature Return Type Description
stdout() FDWriter

Properties

Name Type Description
auto_close Logical
buffer Byte[]
error Logical
fd Int32
position Int32

Methods

Signature Return Type Description
init( fd:Int32, [auto_close=true:Logical] )
close()
flush()
on_cleanup()
on_use() FDWriter
position() Int32
reset()
seek_end()
on_end_use( err:Exception ) Exception
seek( pos:Int32 )
skip( n:Int32 )
write( bytes:Byte[] )
write( ch:Byte )
write( text:String )

FileListing.rogue

enum FileListingOption [bitflags]

Categories

Category Value Description
ABSOLUTE 1
FILES 2
FOLDERS 4
IGNORE_HIDDEN 8
OMIT_PATH 16
RECURSIVE 32
UNSORTED 64

Global Properties

Name Type Description
categories FileListingOption[]

Global Methods

Signature Return Type Description
create( name:String ) FileListingOption
create( value:Int32 ) FileListingOption

Properties

Name Type Description
value Int32

Methods

Signature Return Type Description
description() String
is_absolute() Logical
is_files() Logical
is_folders() Logical
is_ignore_hidden() Logical
is_omit_path() Logical
is_recursive() Logical
is_unsorted() Logical
name() String
operator!() FileListingOption
operator?() Logical
to<>() Int32
to<>() Object
to<>() String
operator&( flag:FileListingOption ) FileListingOption
operator==( other:FileListingOption ) Logical
operator|( flag:FileListingOption ) FileListingOption
set_is_absolute( setting:Logical )
set_is_files( setting:Logical )
set_is_folders( setting:Logical )
set_is_ignore_hidden( setting:Logical )
set_is_omit_path( setting:Logical )
set_is_recursive( setting:Logical )
set_is_unsorted( setting:Logical )

class FileListing

extends Object

Properties

Name Type Description
callback Function(String)
empty_segments String[]
filepath_segments String[]
filepaths String[]
options FileListingOption
path_segments String[]
pattern FilePattern
pattern_segments String[]

Methods

Signature Return Type Description
init( folder_or_filepath:File, _pattern:FilePattern?, options:FileListingOption )
collect( filename:String )
fix( pattern:String ) String Without this fix, "**Alpha*" would not match "Source/Alpha.rogue"

FilePattern.rogue

class FilePattern [compound]

Global Methods

Signature Return Type Description
create( pattern:String ) FilePattern

Properties

Name Type Description
pattern String

Methods

Signature Return Type Description
description() String
to<>() Boxed<<FilePattern>>
to<>() String
matches( filepath:String, &ignore_case ) Logical Determines whether or not the given filepath matches the given semi-Unix/Dos-style 'wildcard pattern'. 'pattern' is a regular text string that may contain the following special characters:

* - Matches any number of characters but does not match '/' ** - Matches any number of characters including slashes ***/ - Matches any number of characters and a slash or else nothing. ? - Matches any one character except '/'

Note: A filepath with a ./ prefix is checked with and without the prefix.
operator==( other:FilePattern ) Logical

FileReader.rogue

class FileReader

extends Object

incorporates Reader<<$DataType>>

Properties

Name Type Description
buffer_position Int32
buffer Byte[]
count Int32
error Logical
filepath String
position Int32

Methods

Signature Return Type Description
init()
init( _filepath:String )
close()
fp() Int64
has_another() Logical
on_cleanup()
on_end_use()
on_use() FileReader
peek() Byte
position() Int32
read() Byte
remaining() Int32
reset()
to<>() Byte[]
to<>() String
on_end_use( this_reader:FileReader )
open( filepath:String ) Logical
read( result:Byte[], limit:Int32 ) Int32
seek( pos:Int32 )
skip( n:Int32 )

Files.rogue

class Files

extends Object

Description

Manages a set of filepath strings.

Properties

Name Type Description
base_folder String
filepath_set [String:String]

Methods

Signature Return Type Description
init( base_folder:File, pattern:FilePattern, &ignore_hidden=true, &include_folders )
init( base_folder:File, pattern:String, &ignore_hidden=true, &include_folders )
init( base_folder:String, &allow_pattern=true, &include_folders )
init( base_folder:String, pattern:FilePattern, &ignore_hidden=true, &include_folders )
init( base_folder:String, pattern:String, &ignore_hidden=true, &include_folders )
count() Int32
filepaths() TableValuesIterator<<String,String>>
files() File[]
newest_timestamp_ms() Int64?
oldest_timestamp() Int64?
relative_filepaths() String[]
relative_files() File[]
to<>() File[]
to<>() String
to<>() String[]
add( pattern:FilePattern, &ignore_hidden=true, &include_folders )
add( pattern:String, &ignore_hidden=true, &include_folders )
any_newer_than( filepath:String ) Logical
contains( file:File ) Logical
contains( filepath:String ) Logical
copy_to( to_folder:File, &if_newer, &if_different, &verbose, &dry_run )
delete( &verbose, &dry_run )
get( index:Int32 ) String
relative_filepath( filepath:String ) String
remove( files:Files ) Removes files from this listing but not from the filesystem - use delete() for that.
remove( pattern:FilePattern ) Removes files from this listing but not from the filesystem - use delete() for that.
remove( pattern:String ) Removes files from this listing but not from the filesystem - use delete() for that.
remove( query:Function(String)->Logical ) Removes files from this listing but not from the filesystem - use delete() for that.
sync_to( dest_folder:File, &verbose, &keep_unused, &dry_run, &missing_only, &if_newer ) Int32 If 'if_newer' is not specified then files are copied if they are different.

FileWriter.rogue

class FileWriter

extends Object

incorporates Writer<<$DataType>>

Properties

Name Type Description
buffer Byte[]
error Logical
filepath String
position Int32

Methods

Signature Return Type Description
init()
init( _filepath:String, append:Logical )
close()
flush()
fp() Int64
on_cleanup()
on_use() FileWriter
position() Int32
reset()
seek_end()
on_end_use( err:Exception ) Exception
on_end_use( this_writer:FileWriter )
open( filepath:String, append:Logical ) Logical
seek( pos:Int32 )
skip( n:Int32 )
write( bytes:Byte[] )
write( ch:Byte )
write( data:String )

MutexFile.rogue

class MutexFile

extends Object

Description

Useful when a re-entrant program needs a mutex - for example a CGI program that is invoked multiple times concurrently.

USAGE
  uses FileIO/MutexFile

  use MutexFile("Mutex")
    ... # do other stuff
  endUse

Properties

Name Type Description
fd Int32
file File

Methods

Signature Return Type Description
init( file:File )
init( filepath:String )
on_use() MutexFile
on_end_use( THISOBJ:MutexFile )
Clone this wiki locally