Product Site

5.4.8.20. init

Initializes a new File instance with the path path (after normalization).

If specified, dir is a parent path that is prepended to path. If dir is a File object then the absolute path of dir is prepended, otherwise dir is prepended as-is (after normalization). The normalization consists in adjusting the separators to the platform's convention and removing the final separator (if any).
Example 5.254. File class — init method
/* Windows */
file = .File~new("file")                     -- file
file = .File~new("c:\program files\")        -- c:\program files
file = .File~new("file", "c:/program files") -- c:\program files\file
'cd c:\program files\oorexx'
samples = .File~new("samples")               -- samples
file = .File~new("file", "samples")          -- samples\file
file = .File~new("file", samples)            -- c:\program files\oorexx\samples\file

/* Unix-like system */
file = .File~new("/opt/ooRexx/")             -- /opt/ooRexx
'cd /opt/ooRexx'
samples = .File~new("samples")               -- samples
file = .File~new("file", "samples")          -- samples/file
file = .File~new("file", samples)            -- /opt/ooRexx/samples/file