1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. package Support.Paths is 
  10.  
  11.     -- If the path has no extension, or if 'force' is True then the path with 
  12.     -- the appended extension is returned. Otherwise, the path is returned 
  13.     -- as-is. The value for 'ext' should not include a leading dot character. 
  14.     function Add_Extension( path, 
  15.                             ext   : String; 
  16.                             force : Boolean := False ) return String; 
  17.     pragma Precondition( path'Length > 0 ); 
  18.     pragma Precondition( ext'Length > 0 ); 
  19.  
  20.     -- If fullpath ends with filename, the ancestor part of fullpath that 
  21.     -- contains filename will be returned. Otherwise, fullpath will be returned. 
  22.     -- 
  23.     -- Example: 
  24.     --   fullpath => "C:\my_dir\something\file.dat" 
  25.     --   filename => "something\file.dat" 
  26.     --   returns "C:\my_dir\" 
  27.     function Ancestor_Dir( fullpath, filename : String ) return String; 
  28.     pragma Precondition( fullpath'Length > 0 ); 
  29.  
  30.     -- Returns the current platform's common application data directory. This is 
  31.     -- where the standard application resources may have been installed. 
  32.     function App_Data_Directory return String; 
  33.  
  34.     -- Returns the file extension for executable files on the current OS without 
  35.     -- a leading dot character. 
  36.     function Executable_Extension return String; 
  37.  
  38.     -- Returns the directory containing the executable file, or, if the executable is 
  39.     -- running on OS X inside an .app bundle, the bundle's Resources directory. 
  40.     function Execution_Directory return String; 
  41.  
  42.     -- Returns the directory portion of a full path, including a directory 
  43.     -- separator at the end. 
  44.     function Get_Directory( path : String ) return String; 
  45.  
  46.     -- Returns the path's file extension without a leading dot character, or an 
  47.     -- empty string if the path has no file extension. 
  48.     function Get_Extension( path : String ) return String; 
  49.  
  50.     -- Returns the path's filename if it has one, otherwise an empty string is 
  51.     -- returned. 
  52.     function Get_Filename( path : String ) return String; 
  53.  
  54.     -- Returns the platform's home directory. The string will have a trailing 
  55.     -- directory separator. 
  56.     function Home_Directory return String; 
  57.  
  58.     -- Recursively creates directory 'path', returning True on success or False 
  59.     -- on error. If the directory already exists, True will be returned. 
  60.     function Make_Dir( path : String ) return Boolean; 
  61.  
  62.     -- Returns the opposite slash of the current platform's directory separator 
  63.     -- slash character. 
  64.     function Other_Slash return String; 
  65.  
  66.     -- Appends 'extra' onto 'basePath', following path naming conventions by 
  67.     -- ensuring that extra one directory separator character is inserted between 
  68.     -- the two path parts. If both 'basePath' and 'extra' are empty then an 
  69.     -- empty string is returned, otherwise if 'basePath' is empty then 'extra' 
  70.     -- is returned, or if 'extra' is empty, then 'basePath' is returned. 
  71.     function Path_Append( basePath, extra : String ) return String; 
  72.  
  73.     -- Returns a path without its file extension. If the path is a directory or 
  74.     -- the file has no extension, it will be returned as-is. 
  75.     function Remove_Extension( path : String ) return String; 
  76.  
  77.     -- Removes all trailing slashes (forward and backward) from tail of 'path'. 
  78.     function Remove_Trailing_Slash( path : String ) return String; 
  79.  
  80.     -- Opens the directory of 'path' in the platform's GUI and selects the 
  81.     -- specific file in 'path', if it points to an existing file. If the 
  82.     -- directory of 'path' does not exist then nothing happens. 
  83.     procedure Reveal_Path( path : String ); 
  84.  
  85.     -- Returns the current platform's directory separator character. 
  86.     function Slash return String; 
  87.     pragma Postcondition( Slash'Result'Length = 1 ); 
  88.  
  89.     -- Returns the current platform's directory for system fonts. 
  90.     function System_Font_Directory return String; 
  91.  
  92.     -- Returns the current platform's temporary directory for temporary files. 
  93.     function Temp_Directory return String; 
  94.  
  95. end Support.Paths;