home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / ppwizard.zip / fileinfo.h < prev    next >
C/C++ Source or Header  |  2000-01-03  |  7KB  |  146 lines

  1. ;----------------------------------------------------------------------------
  2. ;     MODULE NAME:   FILEINFO.H
  3. ;
  4. ;         $Author:   Dennis_Bareis  $
  5. ;       $Revision:   1.1  $
  6. ;           $Date:   03 Jan 2000 09:17:48  $
  7. ;        $Logfile:   E:/DB/PVCS.IT/OS2/PPWIZARD/FILEINFO.H_V  $
  8. ;
  9. ;     DESCRIPTION:   This header allows you to easily verify the existance
  10. ;                    of a local file, and assuming you have a foolproof way
  11. ;                    of transferring changes to your ISP's server (that is
  12. ;                    you have automated the process using a product such as
  13. ;                    "sitecopy") then this will have validated the existance
  14. ;                    on the server as well (at the very least you have not
  15. ;                    miskeyed the name of the download etc).
  16. ;
  17. ;                    The header makes NO assumptions about the position on
  18. ;                    the server versus its position on the local filesystem.
  19. ;                    If the relative position on the local filesystem (to the
  20. ;                    current directory) was the same as the relative position
  21. ;                    on the server from the generated html then a path need
  22. ;                    not be specified.  If you do need to specify a path it
  23. ;                    can either be with the file (and can therefore handle
  24. ;                    more than one local path) or you can make use of the
  25. ;                    default path definition ("FILEINFO_DEFAULT_PATH").
  26. ;                    If the path definition is supplied it must end with a
  27. ;                    slash.
  28. ;
  29. ;                    If all your file information is to be generated in a
  30. ;                    different font (or bold, italic etc) then you can make
  31. ;                    use of the "FONT" related definitions, by default they
  32. ;                    are only suitable for html generation and make the font
  33. ;                    slightly smaller.  You can also create empty values if
  34. ;                    you don't wish the font to change.  You could create
  35. ;                    your own "front end" such as this one (for html):
  36. ;
  37. ;                         #define  BoldSizeOfFile <B><$SizeOfFile {$?}></B>
  38. ;
  39. ;                    Note that there are 2 levels of default, the #define
  40. ;                    values set the default for all the macros while the
  41. ;                    "SFONT" and "EFONT" parameters can be used to specify
  42. ;                    the complete start and end font tags on an individual
  43. ;                    use.
  44. ;----------------------------------------------------------------------------
  45.  
  46.  
  47. ;--- Start of Header (include only once) ------------------------------------
  48. #ifndef VERSION_FILEINFO_H
  49.         #define   VERSION_FILEINFO_H    99.358
  50.         #require  99.311
  51.  
  52.  
  53. ;--- Defaults ---------------------------------------------------------------
  54. #ifndef    FILEINFO_DEFAULT_PATH
  55.            #define FILEINFO_DEFAULT_PATH           ;;No path by default (note filename can contain all or partial path)
  56. #endif
  57. #ifndef    FILEINFO_FONT
  58.            #define FILEINFO_FONT  <FONT SIZE="-1"> ;;Can be empty for no font change!
  59. #endif
  60. #ifndef    FILEINFO_/FONT
  61.            #define FILEINFO_/FONT </FONT>          ;;Can be empty for no font change!
  62. #endif
  63. #ifndef    FILEINFO_AM
  64.            #define FILEINFO_AM    am               ;;Change to whatever you wish
  65. #endif
  66. #ifndef    FILEINFO_PM
  67.            #define FILEINFO_PM    pm               ;;Change to whatever you wish
  68. #endif
  69.  
  70.  
  71. ;--- Code to validate and format file information ---------------------------
  72. #DefineRexx RexxVerifyLocalInputFile
  73.             ;--- Allow specification of file with relative url dir ----------
  74.             #if '<?OpSys>' = 'UNIX'
  75.                 LocalFile = "{$PATH='<$FILEINFO_DEFAULT_PATH>'}{$File}";
  76.             #elseif
  77.                 LocalFile = ReplaceString("{$PATH='<$FILEINFO_DEFAULT_PATH>'}{$File}", "/", "\");
  78.             #endif
  79.  
  80.             ;--- Make sure the file exists ----------------------------------
  81.             if stream(LocalFile, "c", "query exists") = '' then
  82.                Error('The file "' || LocalFile || '" does not exist!');
  83.  
  84.             ;--- Mark as input dependancy -----------------------------------
  85.             call AddInputFileToDependancyList LocalFile;
  86. #DefineRexx
  87. #DefineRexx RexxSizeOfFile
  88.             RxFileSize    = stream(LocalFile, "c", "query size");
  89.             RxFileSizeCma = AddCommasToDecimalNumber(RxFileSize);
  90. #DefineRexx
  91. #DefineRexx RexxDateOfFile
  92.             ;--- Get file date/time -----------------------------------------
  93.             RxFileStamp   = GetFileTimeStamp(LocalFile);
  94.  
  95.             ;--- Format the date (3 NOV 1999) -------------------------------
  96.             RxFileDay     = substr(RxFileStamp, 7, 2) + 0; ;;Remove leading '0'
  97.             RxFileMonth   = substr(RxFileStamp, 5, 2);
  98.            ;RxFileYear    = substr(RxFileStamp, 1, 4);    ;;4 digit
  99.             RxFileYear    = substr(RxFileStamp, 3, 2);    ;;2 digit
  100.             RxFileMon     = word('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec', RxFileMonth);
  101.             RxFileTime    = RxFileDay || ' ' || RxFileMon || ' ' || RxFileYear;
  102. #DefineRexx
  103. #DefineRexx RexxTimeOfFile
  104.             ;--- Get file date/time -----------------------------------------
  105.             RxFileStamp   = GetFileTimeStamp(LocalFile);
  106.  
  107.             ;--- Format the date (3 NOV 1999) -------------------------------
  108.             RxFileHour    = substr(RxFileStamp, 9,  2) + 0; ;;Remove leading '0'
  109.             RxFileMinute  = substr(RxFileStamp, 11, 2);
  110.             if RxFileHour < 12 then
  111.                RxAmPm = '<$FILEINFO_AM>';
  112.             else
  113.                RxAmPm = '<$FILEINFO_PM>';
  114.             if RxFileHour > 12 then
  115.                RxFileHour = RxFileHour - 12;
  116.             RxFileTime    = RxFileHour || ':' || RxFileMinute || RxAmPm;
  117. #DefineRexx
  118.  
  119. ;--- Specialized macros -----------------------------------------------------
  120. #define   SizeOfFile                                                           \
  121.           #evaluate+  ^^ ^<$RexxVerifyLocalInputFile {$?}>;<$RexxSizeOfFile>^ -\
  122.           {$SFONT=^<$FILEINFO_FONT>^}                                         -\
  123.                 {$Before=""}<??RxFileSizeCma> bytes{$After=""}                -\
  124.           {$EFONT=^<$FILEINFO_/FONT>^}
  125. #define   DateOfFile                                                           \
  126.           #evaluate+  ^^ ^<$RexxVerifyLocalInputFile {$?}>;<$RexxDateOfFile>^ -\
  127.           {$SFONT=^<$FILEINFO_FONT>^}                                         -\
  128.                 {$Before=""}<??RxFileTime>{$After=""}                         -\
  129.           {$EFONT=^<$FILEINFO_/FONT>^}
  130. #define   TimeOfFile                                                           \
  131.           #evaluate+  ^^ ^<$RexxVerifyLocalInputFile {$?}>;<$RexxTimeOfFile>^ -\
  132.           {$SFONT=^<$FILEINFO_FONT>^}                                         -\
  133.                 {$Before=""}<??RxFileTime>{$After=""}                         -\
  134.           {$EFONT=^<$FILEINFO_/FONT>^}
  135.  
  136. ;--- Information in (brackets) ----------------------------------------------
  137. #define   (SizeOfFile) <$SizeOfFile {$?} BEFORE="(" AFTER=")">
  138. #define   (DateOfFile) <$DateOfFile {$?} BEFORE="(" AFTER=")">
  139.  
  140.  
  141. ;--- End of Header ----------------------------------------------------------
  142. #endif
  143.  
  144.  
  145.  
  146.