home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / fileinpp.zip / fileinfo.h
C/C++ Source or Header  |  1999-11-07  |  7KB  |  136 lines

  1. ;----------------------------------------------------------------------------
  2. ;     MODULE NAME:   FILEINFO.H
  3. ;
  4. ;         $Author:   Dennis_Bareis  $
  5. ;       $Revision:   1.2  $
  6. ;           $Date:   02 Oct 1999 18:40:58  $
  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. ;
  40. ;----------------------------------------------------------------------------
  41.  
  42.  
  43. ;--- Start of Header (include only once) ------------------------------------
  44. #ifndef VERSION_FILEINFO_H
  45.         #define   VERSION_FILEINFO_H    99.311
  46.         #require  99.311
  47.  
  48.  
  49. ;--- Defaults ---------------------------------------------------------------
  50. #ifndef    FILEINFO_DEFAULT_PATH
  51.            #define FILEINFO_DEFAULT_PATH           ;;No path by default (note filename can contain all or partial path)
  52. #endif
  53. #ifndef    FILEINFO_FONT
  54.            #define FILEINFO_FONT  <FONT SIZE="-1"> ;;Can be empty for no font change!
  55. #endif
  56. #ifndef    FILEINFO_/FONT
  57.            #define FILEINFO_/FONT </FONT>          ;;Can be empty for no font change!
  58. #endif
  59.  
  60.  
  61. ;--- Code to validate and format file information ---------------------------
  62. #DefineRexx RexxVerifyLocalInputFile
  63.             ;--- Allow specification of file with relative url dir ----------
  64.             #if '<?OpSys>' = 'UNIX'
  65.                 LocalFile = "{$PATH='<$FILEINFO_DEFAULT_PATH>'}{$File}";
  66.             #elseif
  67.                 LocalFile = ReplaceString("{$PATH='<$FILEINFO_DEFAULT_PATH>'}{$File}", "/", "\");
  68.             #endif
  69.  
  70.             ;--- Make sure the file exists ----------------------------------
  71.             if stream(LocalFile, "c", "query exists") = '' then
  72.                Error('The file "' || LocalFile || '" does not exist!');
  73.  
  74.             ;--- Mark as input dependancy -----------------------------------
  75.             call AddInputFileToDependancyList LocalFile;
  76. #DefineRexx
  77. #DefineRexx RexxSizeOfFile
  78.             RxFileSize    = stream(LocalFile, "c", "query size");
  79.             RxFileSizeCma = AddCommasToDecimalNumber(RxFileSize);
  80. #DefineRexx
  81. #DefineRexx RexxDateOfFile
  82.             ;--- Get file date/time -----------------------------------------
  83.             RxFileStamp   = GetFileTimeStamp(LocalFile);
  84.  
  85.             ;--- Format the date (3 NOV 1999) -------------------------------
  86.             RxFileDay     = substr(RxFileStamp, 7, 2) + 0; ;;Remove leading '0'
  87.             RxFileMonth   = substr(RxFileStamp, 5, 2);
  88.            ;RxFileYear    = substr(RxFileStamp, 1, 4);    ;;4 digit
  89.             RxFileYear    = substr(RxFileStamp, 3, 2);    ;;2 digit
  90.             RxFileMon     = word('Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec', RxFileMonth);
  91.             RxFileTime    = RxFileDay || ' ' || RxFileMon || ' ' || RxFileYear;
  92. #DefineRexx
  93. #DefineRexx RexxTimeOfFile
  94.             ;--- Get file date/time -----------------------------------------
  95.             RxFileStamp   = GetFileTimeStamp(LocalFile);
  96.  
  97.             ;--- Format the date (3 NOV 1999) -------------------------------
  98.             RxFileHour    = substr(RxFileStamp, 9,  2) + 0; ;;Remove leading '0'
  99.             RxFileMinute  = substr(RxFileStamp, 11, 2);
  100.             if RxFileHour < 12 then
  101.                RxAmPm = 'a';
  102.             else
  103.                RxAmPm = 'p';
  104.             if RxFileHour > 12 then
  105.                RxFileHour = RxFileHour - 12;
  106.             RxFileTime    = RxFileHour || ':' || RxFileMinute || RxAmPm;
  107. #DefineRexx
  108.  
  109. ;--- Specialized macros -----------------------------------------------------
  110. #define   SizeOfFile                                                           \
  111.           #evaluate+  ^^ ^<$RexxVerifyLocalInputFile {$?}>;<$RexxSizeOfFile>^ -\
  112.           <$FILEINFO_FONT>                                                    -\
  113.                 {$Before=""}<??RxFileSizeCma> bytes{$After=""}                -\
  114.           <$FILEINFO_/FONT>
  115. #define   DateOfFile                                                           \
  116.           #evaluate+  ^^ ^<$RexxVerifyLocalInputFile {$?}>;<$RexxDateOfFile>^ -\
  117.           <$FILEINFO_FONT>                                                    -\
  118.                 {$Before=""}<??RxFileTime>{$After=""}                         -\
  119.           <$FILEINFO_/FONT>
  120. #define   TimeOfFile                                                           \
  121.           #evaluate+  ^^ ^<$RexxVerifyLocalInputFile {$?}>;<$RexxTimeOfFile>^ -\
  122.           <$FILEINFO_FONT>                                                    -\
  123.                 {$Before=""}<??RxFileTime>{$After=""}                         -\
  124.           <$FILEINFO_/FONT>
  125.  
  126. ;--- Information in (brackets) ----------------------------------------------
  127. #define   (SizeOfFile) <$SizeOfFile {$?} BEFORE="(" AFTER=")">
  128. #define   (DateOfFile) <$DateOfFile {$?} BEFORE="(" AFTER=")">
  129.  
  130.  
  131. ;--- End of Header ----------------------------------------------------------
  132. #endif
  133.  
  134.  
  135.  
  136.