::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:
class Os.Platform.Public  public Gilda:  Portable system calls

  type Platform  in Vc, W32    :Target and host platforms

  type Attribute  is           &Status information for a file or directory.
      Dir = -1  word,          &  0 if a file, 1 if a directory,
                               & -1 if not found, -2 if a unix link.
      Date      word,          &OS encoded time of the last modification.

      Size      cell,          &Size of a file
      Read      Bit,           &Path has read permission
      Write     Bit,           &Path has write permission
      Execute   Bit,           &An executable file

      File         |=  0,      &Path is a file
      Directory    |=  1,      &Path is a directory
      Missing      |= -1,      &Path item is missing
      Link         |= -2,      &Path is a Unix link
      Is( .Member ) => $Dir = $.Member   :Test if a File, Directory, Missing, or Link


  type C.String  is        &Structure for accessing a null terminated string.
     @C[?]   byte          :At the C string.

  type C.String.Put  is   &Structure for writing to a null terminated string.
     *C[?]   byte         :C string Wizard.

  type C.String.Cast  is  &Structure for converting strings.
     @C[?] = 0  byte,     &At the C string.
      Head[span(@) - 1]   byte :Storage for a short string.

global New.Line    |= "^M^J",          &Preferred line separator for output
      +Path.Slash   = '\'  Byte,       &Display slash format; may be '/' or '\'
      +Home.Path           string,     &Full home (lower case, trailing path.slash)
      +Home.Share          string,     &Home.Drive alias (lower; no trailing slash)
      +Home.Drive          byte,       &Drive letter for the home path (upper case)

       Null.Device |= "nul",           &File name used to discard output
       Browser     |= "EXPLORER.EXE",  &File system browser application
       Special     |=                  &Path characters requiring quotes
          " ""'`*#?!%=~,(){}[]<>|^^&;"

global Library.Suffix |= ".lib",       &Static library file suffix
       Dynamic.Suffix |= ".dll",       &Dynamic library file suffix
       Environment    |= ';'           :Environment variable list delimiter
:
:...............................................................................



::::::::::::::::::::::::::::  Common C Procedures  :::::::::::::::::::::::::::::
:
function TO.STRING:  Copy a null terminated C string to a Gilda string.

 entry C[?]   byte              :C string address; contiguous bytes, ending in a 0 byte

  exit Text   string            :Gilda string
:
:...............................................................................
:
function TO.C.STRING:  Copy a Gilda string to a C string.

 entry String                   :Gilda string containing no zero bytes

  exit C[?] = ?   byte          :Array for the C string:  0 to length[ $ ] + 1
:
:  Fault if the Gilda string contains an zero bytes.
:...............................................................................
:
function CAST_TYPE:  Here to suppress the compile; only use as an alias.???

 entry From[0]   byte           :Address to be cast

  exit *To[?]    byte           :Same address; different type via an alias.
:
:...............................................................................
:
method "ERROREXIT":  Fatal exit from C code.

 entry Message[?]  byte         :Exit message
:
:...............................................................................



::::::::::::::::::::::::::::  File Procedures  :::::::::::::::::::::::::::::::::
:
method FILE.ATTRIBUTE:  Find a file on the path.  I32 version.

change Path    string           : In - Os path directory (end with a slash).
                                :Out - Os path of a file if found; else junk.

 entry File    string           :File to look up on the path search list.

  exit Attribute                :File information.  Info..Dir = 0 if a match.
:
:...............................................................................
:
function FILE.TIME:  Convert an encoded time into a 12 character format.

 entry Time    word             :Seconds since the epoch.

  exit Form    string
:
:...............................................................................
:
function FILE.SIZE: Get the number of bytes in a file.

 entry String                   :OS Path name of the file to check.

  exit Size  cell               :Size of the file or < 0 if an error.
:
:...............................................................................
:
method FILE_INDEX:  Returns the current file position.

 entry File                     :File Id

  exit Index[0]  cell           :File position
:
:...............................................................................
:
function PROGRAM.PATH:  Get the path of the program that calls this function.

  exit Path   string            :Tame relative OS path (forward slashes).
:
:...............................................................................
:
method PROGRAM_PATH  pure:  Get the path of the program that calls this method.

change Text[?]   byte           :Tame relative OS path (forward slashes).
:
:...............................................................................
:
method IS.PROGRAM.GRAPHICAL:  Determine if a program runs in a window.

 entry Program  string          :OS path name of the file to check.

  exit Window   Bit             :1 - A window program; else 0.
:
:...............................................................................
:
method IS.PROGRAM.FILE:  Determine if a file is a program or not.

 entry File     string          :OS path name of the file to check.

  exit Program  Bit             :A program if On, else 0.
:
:...............................................................................
:
method DUAL.HIDDEN:  Noop on Windows.  Hidden is a file attribute.

 entry Dual    string           :Dual path name (may be wild).

change Hidden  Bit              :Unchanged.
:
:..............................................................................
:
method TOUCH.FILE:  Set the file date to now.

 entry File   string
:
:...............................................................................
:
method MOVE.FILE.STATUS:  Move a file and return the status.

 entry From   string,
       To     string

  exit Status[0]  byte
:...............................................................................
:
method COPY.FILE.STATUS:  Copy a file and return the status.

 entry From   string,
       To     string

  exit Status[0]  byte
:...............................................................................



::::::::::::::::::::::  Directory Procedures  ::::::::::::::::::::::::::::::::::
:
method MAKE.DIRECTORY:  Create a new directory.

 entry Path   string            :Os path of the directory to make.
:
:...............................................................................
:
method DELETE.EMPTY.DIRECTORY:  Delete an empty directory.

 entry Directory  string

  exit Status     byte          : 0 - Okay
                                : 1 - No permission
                                : 2 - Can't delete.
                                : 3 - Misc. Error.
                                : 4 - Directory in use.
                                : 5 - Directory not empty.
                                : 6 - Write protected drive.
:
:...............................................................................
:
method OPEN_DIRECTORY:  Begin scanning a directory.

 entry Id[0]    Directory.Id,    &uint32  *
       Text[?]  byte
:
:...............................................................................
:
method NEXT_DIRECTORY:  Get the next item in a directory.

change Id[0]    Directory.Id,    &uint32  *
       Text[0]  C.String         :uint8  **
:
:...............................................................................
:
method NEXT_ATTRIBUTE:  Get the next item in a directory with attributes.

change Id[0]    Directory.Id,   &At an open directory id.
       Text[0]  C.String,       &Place to return the string address or a null string if none.
       Attribute                :path information
:
:...............................................................................
:
method CLOSE_DIRECTORY  pure:  Close a directory scan.

change Id[0]  Directory.Id
:
:...............................................................................
:
method SAVE_DIRECTORY:  Temporarily save the directory scan state.
:
:...............................................................................
:
method RESTORE_DIRECTORY:  Restore the scan state saved by Save_Directory.
:
:...............................................................................



:::::::::::::::::::::::::::::::  Path Procedures  ::::::::::::::::::::::::::::::
:
method RENAME.PATH:  Rename a file or directory.

 entry Old   string,
       New   string

  exit Status[0]  byte
:
:...............................................................................
:
method RENAME_PATH:  Rename a file or directory.

 entry Old[?]     byte,
       New[?]     byte

change Status[0]  byte
:
:...............................................................................
:
function PATH.ATTRIBUTE:  Get status information about a file or directory.

 entry Path   string :O.S. relative path (no wildcards, Os slashes).

  exit Attribute
:
:...............................................................................
:
method IS.HIDDEN.PATH:  See if an OS path is hidden.

 entry Os.Path   string         :Tame OS path to check.

  exit Hidden    Bit
:
:...............................................................................
:
method IS.REMOTE.PATH:  See if an OS path is a shared net path.

 entry Os.Path    string        :Tame OS path to check.

  exit Remote     Bit           :on for //, ///, ////, //server, //server/share
:
:...............................................................................
:
method IS.NETWORK.PATH:  See if an OS path is a shared net path.

 entry Os.Path  string          :Tame OS path to check.

  exit Shared   Bit             :1 - //, ///, ////, //server, //server/share
:
:...............................................................................
:
method FORM.BASE.OS.PATH  pure:  Windows version converts slashes to back slashes.

change Path   string     :In - Os Path to convert; Out - Cannonical OS path.
:
:...............................................................................
:
method FORM.LONG.PATH:  Convert a windows 8.3 name to a long name.

change Path    string     : In - Os path (Tame, relative, back slash, no trail).
                          :Out - A path name beginning from the root.
:
:  Unchanged on nix
:...............................................................................
:
method DEFORM.PATH.NAME:  Extract the Os path name from the display name.

change Path    string          : In - Display name; which may contain quoted
                               :      elements or a trailing tilda indicating an
                               :      executable (any slashes).
                               :Out - Raw os path name (slashes are unchanged).
:
:...............................................................................



::::::::::::::::::::::::::::  Utility Procedures  ::::::::::::::::::::::::::::::
:
function TIME_1970:  Number of seconds since UTC 1/1/1970

  exit Time    cell
:
:...............................................................................
:
method SLEEP_MS:  Pause a process.

 entry Time    word     :Number of milliseconds to pause.
:
:...............................................................................
:
method WARNING_BELL:  Beep
:
:...............................................................................
:
method LOGOUT_NOW:  Exit a process with extreme predjudice.
:
:...............................................................................
:
method LOGOUT:  Exit a process.
:
:...............................................................................
:
method INSERT_CLIP:  Get text from the system clipboard.
:
:...............................................................................
:
method COPY_CLIP:  Save text to the sytem clipboard.

 entry Size    word     :Number of characters (non-zero).
:
:...............................................................................

method EXIT_PROGRAM

 entry Status = 0  word
:
:...............................................................................
:
function GET.HOST:  Get the host machine name.

  exit Host   string     :The host machine name (upper case).
:
:...............................................................................
:
function GET.WORK:  Get the current working directory.

  exit Path   string     :Tame relative path (trailing forward slash).
:
:...............................................................................
:
method SHELL.PATH:  Get the path for a verb.

 entry Verb     string

  exit Path     string          :O.S. Path
:
:...............................................................................
:
method SHELL.FILE:  Launch a file base on it's type.

 entry Command   string         :File path

  exit Status    Bit            :Status returned from the command.
:
:...............................................................................
:
method SYSTEM.SHELL:  Pass a command to the system shell.

 entry Command   string         :Command to execute.

  exit Status    word           :Status returned from the command.
:
:...............................................................................
:
method RUN_NET_DIRECTORY:  Cache accessible network directories.
:
: Run once to start caching in the background.
: Before accessing a network path, run again to wait for caching to complete.
:...............................................................................
:
method RESET_NET_DIRECTORY:  Add new accessible network directories to the Cache.

: Existing hosts shares are not removed.  Only new items are added.
: Before accessing a network path, run RUN_NET_DIRECTORY to wait for caching to complete.
:
:...............................................................................


end