home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / d / desklib / !DeskLib / h_doc / Filing < prev    next >
Encoding:
Text File  |  1997-01-22  |  27.9 KB  |  730 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Filing.h
  12.     Author:  Copyright © 1994, 1995 Sergio Monesi, Julian Smith
  13.     Version: 1.04 (27 Aug 1995)
  14.     Purpose: Easy access to files informations, directory scans, filenames
  15.              handling.
  16.     Mods:    06 Jun 1995 - changed some procedure names to a more
  17.                            DeskLib-compliant style
  18.              15 Jul 1995 - added Desk_Filing_CanonicalisePath
  19.              27 Aug 1995 - made Desk_Filing_ScanDir and Desk_Filing_ScanDirByDir
  20.                            reentrant. Added Desk_Filing_SingleDirEntry and
  21.                            Desk_Filing_SingleDirEntry2
  22.              13 Sep 1995 - JS - Added 'void *reference' to Desk_Filing_ScanDir
  23.                                 and Desk_Filing_ScanDirByDir.
  24.                                 Added Desk_filing_scan_PRUNE.
  25.                                 Renamed the function-pointer typedefs used 
  26.                                 in Desk_Filing_ScanDir and Desk_Filing_ScanDirByDir.
  27.              21 Sep 1995 - JS - Added Desk_Filing_CompareDates.
  28.              17 Dec 1996 - JS - Added Desk_Filing_OpenDir2().
  29.              22 Jan 1997 - JS - Desk_Filing_CloseDir now returns void.
  30. */
  31.  
  32. #ifndef __Desk_Filing_h
  33. #define __Desk_Filing_h
  34.  
  35. #ifdef __cplusplus
  36.     extern "C" {
  37. #endif
  38.  
  39. #ifndef __Desk_Core_h
  40.     #include "Desk.Core.h"
  41. #endif
  42.  
  43.  
  44.   #ifndef Desk_filing_MAXLEAFNAMELEN
  45.     #define Desk_filing_MAXLEAFNAMELEN 32
  46. /*
  47.  
  48.   MACRO:    Constant: Desk_filing_MAXLEAFNAMELEN
  49.  
  50.   Purpose:  The maximum length of a leafname (ie. the filename without the
  51.             path) that can be stored in a Desk_filing_direntry or
  52.             Desk_filing_fulldirentry structure.
  53.             A value of 13 is enough for FileCore based filing system
  54.             (like ADFS, IDEFS, SCSI, etc.) and for DOS discs.
  55.             A value of 32 seems to be reasonable for every filing system.
  56.             You can #define it before including this header if you want
  57.             to be sure that it is set to the desired value (ie. even if
  58.             someone changes this header, your value will be still valid).
  59.   SeeAlso:  Desk_filing_direntry; Desk_filing_fulldirentry;
  60.  
  61.  */
  62.   #endif
  63.  
  64.  
  65.  
  66.   typedef enum {
  67.     Desk_filing_NOTFOUND  = 0,
  68.     Desk_filing_FILE      = 1,
  69.     Desk_filing_DIRECTORY = 2,
  70.     Desk_filing_IMAGEFILE = 3
  71.   } Desk_filing_objtype;
  72. /*
  73.  
  74.   Purpose:  Object types.
  75.   Fields:   -
  76.   SeeAlso:  Desk_filing_direntry; Desk_filing_fulldirentry;
  77.  
  78.  */
  79.  
  80.  
  81.  
  82.  
  83.   typedef struct {
  84.     int            loadaddr;
  85.     int            execaddr;
  86.     int            length;
  87.     int            attrib;
  88.     Desk_filing_objtype objtype;
  89.     char           name[ Desk_filing_MAXLEAFNAMELEN];
  90.   } Desk_filing_direntry;
  91. /*
  92.  
  93.   Purpose:  Contains file informations (read from directory)
  94.   Fields:   Auto-explicatives...
  95.   SeeAlso:  Desk_filing_fulldirentry;
  96.  
  97.  */
  98.  
  99.  
  100.  
  101.   typedef struct {
  102.     int            loadaddr;
  103.     int            execaddr;
  104.     int            length;
  105.     int            attrib;
  106.     Desk_filing_objtype objtype;
  107.     int            SIN;
  108.     char           date[ 5];
  109.     char           name[ Desk_filing_MAXLEAFNAMELEN];
  110.   } Desk_filing_fulldirentry;
  111. /*
  112.  
  113.   Purpose:  Contains full file informations (read from directory)
  114.   Fields:   Auto-explicatives...
  115.   SeeAlso:  Desk_filing_direntry;
  116.  
  117.  */
  118.  
  119.  
  120.  
  121.  
  122.   typedef enum {
  123.     Desk_readdirtype_DIRENTRY,
  124.     Desk_readdirtype_FULLDIRENTRY,
  125.     Desk_readdirtype_NAMEONLY
  126.   } Desk_filing_readdirtype;
  127. /*
  128.  
  129.   Purpose:  These are the way in which the objects in a directory can be
  130.             read using Desk_Filing_ReadDir function.
  131.   Fields:   Desk_readdirtype_DIRENTRY - reads Desk_filing_direntry objects
  132.             Desk_readdirtype_FULLDIRENTRY - reads Desk_filing_fulldirentry objects
  133.             Desk_readdirtype_NAMEONLY - reads just the names of the files
  134.   SeeAlso:  Desk_filing_direntry; Desk_filing_fulldirentry; Desk_Filing_OpenDir;
  135.             Desk_Filing_ReadDir;
  136.  
  137.  */
  138.  
  139.  
  140.  
  141.   typedef struct {
  142.     char               *dirname;
  143.     void               *buf;
  144.     int                size;
  145.     Desk_filing_readdirtype type;
  146.     union {
  147.       Desk_filing_direntry     *direntry;
  148.       Desk_filing_fulldirentry *fulldirentry;
  149.       char                *name;
  150.       void                *act;
  151.     } act;
  152.     int  offset;
  153.     int  read;
  154.     char *match;
  155.   } Desk_filing_dirdata;
  156. /*
  157.  
  158.   Purpose:  Contains the data needed by Desk_Filing_OpenDir, Desk_Filing_ReadDir and
  159.             Desk_Filing_CloseDir. It is automatically filled by Desk_Filing_OpenDir
  160.             and updated by Desk_Filing_ReadDir. It should not be used by the
  161.             user, apart from the 'act' field that should be used to read
  162.             the current object.
  163.   Fields:   The fields should be ignored since they are for internal use.
  164.             The only important field is:
  165.             act - this union contains the current object that will be
  166.                   returned by Desk_Filing_ReadDir. Remember that you should
  167.                   only use the type chosen when you called Desk_Filing_OpenDir
  168.   SeeAlso:  Desk_filing_direntry; Desk_filing_fulldirentry; Desk_filing_readdirtype;
  169.             Desk_Filing_OpenDir; Desk_Filing_ReadDir; Desk_Filing_CloseDir;
  170.  
  171.  */
  172.  
  173.  
  174.  
  175.   void    Desk_Filing_OpenDir( const char *dirname, Desk_filing_dirdata *dirdata,
  176.                             int bufsize, Desk_filing_readdirtype type);
  177. /*
  178.  
  179.   Purpose:  Prepares a directory to be read with Desk_Filing_ReadDir (ie.
  180.             allocates the buffer and set the starting parameters). After
  181.             the directory has been read, Desk_Filing_CloseDir should be called
  182.             to free the buffer.
  183.   Inputs:   dirname - the directory pathname
  184.             dirdata - a pointer to a (already allocated!) structure that
  185.                       will be filled in by the function
  186.             bufsize - the size of the buffer that should be allocated. Note
  187.                       that the buffer will be allocated by Desk_Filing_OpenDir
  188.                       itself, you just have to give it the size, so that you
  189.                       can save some memory (but remember that, the bigger
  190.                       the buffer, the faster the reading). bufsize should
  191.                       be at least the size of Desk_filing_direntry,
  192.                       Desk_filing_fulldirentry or leafname maxlength, depending
  193.                       on the type you want to read
  194.             type - the type of data you want to read from the directory
  195.                    using Desk_Filing_ReadDir
  196.   Outputs:  -
  197.   Returns:  NULL if no error, otherwise the error generated by RISC OS.
  198.             If an error is returned, the buffer is not allocated
  199.   Errors:   The following custom errors could be returned (apart from the
  200.             RISC OS generated ones):
  201.             &00801C00 - Out of memory
  202.             &00801C01 - Directory is actually a file
  203.             &00801C02 - Directory doesn't exist
  204.   SeeAlso:  Desk_filing_direntry; Desk_filing_fulldirentry; Desk_filing_readdirtype;
  205.             Desk_Filing_ReadDir; Desk_Filing_CloseDir;
  206.  
  207.  */
  208.  
  209.  
  210. void    Desk_Filing_OpenDir2( const char *dirname, Desk_filing_dirdata *dirdata,
  211.                             int bufsize, Desk_filing_readdirtype type, const char* wildcard);
  212. /*
  213. As Desk_Filing_OpenDir, except it accepts a wildcarded leafname
  214. specifier.
  215.  */
  216.  
  217.  
  218.  
  219.  
  220.   void *Desk_Filing_ReadDir( Desk_filing_dirdata *dirdata);
  221. /*
  222.  
  223.   Purpose:  Reads the directory content, one object each call.
  224.             Desk_Filing_OpenDir must be called before this and Desk_Filing_CloseDir
  225.             must be called when there are no more entries to read
  226.   Inputs:   dirdata - a pointer to a structure that defines the directory
  227.                       that will be read. This structure should have been
  228.                       already filled by Desk_Filing_OpenDir
  229.   Outputs:  -
  230.   Returns:  The next object to read in the directory or NULL if finished.
  231.             The returned value is a pointer to a Desk_filing_direntry,
  232.             Desk_filing_fulldirentry or char depending from the type set with
  233.             Desk_Filing_OpenDir
  234.   Errors:   Generally no errors should be caused by this function, since
  235.             they should be already discovered by Desk_Filing_OpenDir. Anyway,
  236.             if something strange happens, a NULL pointer will be
  237.             returned
  238.   SeeAlso:  Desk_Filing_OpenDir; Desk_Filing_CloseDir; Desk_filing_direntry;
  239.             Desk_filing_fulldirentry; Desk_filing_readdirtype;
  240.  
  241. */
  242.  
  243.  
  244.  
  245.   void Desk_Filing_CloseDir( Desk_filing_dirdata *dirdata);
  246. /*
  247.  
  248.   Purpose:  Closes a directory after it has been opened with Desk_Filing_OpenDir
  249.             and read with Desk_Filing_ReadDir. This function frees the buffer
  250.             allocated by Desk_Filing_OpenDir.
  251.             This function can be called more than once for the same dirdata - 
  252.             calls after the first will have ano effect. This can simplify error
  253.             handling.
  254.   Inputs:   dirdata - a pointer to a structure that defines the directory
  255.                       that will be closed.
  256.   Outputs:  -
  257.   Returns:  -
  258.   Errors:   -
  259.   SeeAlso:  Desk_Filing_OpenDir; Desk_Filing_ReadDir; Desk_filing_direntry;
  260.             Desk_filing_fulldirentry; Desk_filing_readdirtype;
  261.  
  262.  */
  263.  
  264.  
  265.  
  266.   void    Desk_Filing_ReadDirNames( const char *dirname, char *buf,
  267.                                  int *number, int *offset,
  268.                                  int size, const char *match);
  269. /*
  270.  
  271.   Purpose:  Reads the directory content (only the file names): this function
  272.             can be called more than once if the content is greater than the
  273.             size of the buffer.
  274.             (veneer for SWI Desk_OS_GBPB 9)
  275.   Inputs:   dirname - the directory pathname
  276.             buf - pointer to a buffer where the content will be stored
  277.             number - number of elements to read
  278.             offset - the offset to the first element to read
  279.             size - the length of the buffer
  280.             match - (wildcarded) filename to match
  281.   Outputs:  number - the number of elements read
  282.             offset - the next element to read or -1 if finished
  283.   Returns:  NULL if no error, otherwise the error returned by RISC OS
  284.   Errors:   -
  285.   SeeAlso:  Desk_Filing_ReadDirEntry; Desk_Filing_ReadFullDirEntry;
  286.  
  287.  */
  288.  
  289.  
  290.  
  291.   void    Desk_Filing_ReadDirEntry( const char *dirname, Desk_filing_direntry *buf,
  292.                                  int *number, int *offset,
  293.                                  int size, const char *match);
  294. /*
  295.  
  296.   Purpose:  Reads the directory content: this function can be called more
  297.             than once if the content is greater than the size of the buffer.
  298.             (veneer for SWI Desk_OS_GBPB 10)
  299.   Inputs:   dirname - the directory pathname
  300.             buf - pointer to a buffer where the content will be stored
  301.             number - number of elements to read
  302.             offset - the offset to the first element to read
  303.             size - the length of the buffer
  304.             match - (wildcarded) filename to match
  305.   Outputs:  number - the number of elements read
  306.             offset - the next element to read or -1 if finished
  307.   Returns:  NULL if no error, otherwise the error returned by RISC OS
  308.   Errors:   -
  309.   SeeAlso:  Desk_filing_direntry; Desk_Filing_ReadDirNames; Desk_Filing_ReadFullDirEntry;
  310.  
  311.  */
  312.  
  313.  
  314.  
  315.   void    Desk_Filing_ReadFullDirEntry( const char *dirname, Desk_filing_fulldirentry *buf,
  316.                                      int *number, int *offset,
  317.                                      int size, const char *match);
  318. /*
  319.  
  320.   Purpose:  Reads the directory content (full info version): this function
  321.             can be called more than once if the content is greater than the
  322.             size of the buffer.
  323.             (veneer for SWI Desk_OS_GBPB 11)
  324.   Inputs:   dirname - the directory pathname
  325.             buf - pointer to a buffer where the content will be stored
  326.             number - number of elements to read
  327.             offset - the offset to the first element to read
  328.             size - the length of the buffer
  329.             match - (wildcarded) filename to match
  330.   Outputs:  number - the number of elements read
  331.             offset - the next element to read or -1 if finished
  332.   Returns:  NULL if no error, otherwise the error
  333.   Errors:   Every possible error returned by RISC OS
  334.   SeeAlso:  Desk_filing_fulldirentry; Desk_Filing_ReadDirNames; Desk_Filing_ReadDirEntry;
  335.  
  336.  */
  337.  
  338.  
  339.  
  340.   void    Desk_Filing_ReadCatalogue( const char *filename, Desk_filing_objtype *objtype,
  341.                                   int *loadaddr, int *execaddr, int *length,
  342.                                   int *attrib, int *filetype);
  343. /*
  344.  
  345.   Purpose:  Reads file informations.
  346.             (veneer for SWI Desk_OS_File 20)
  347.   Inputs:   filename - the file pathname
  348.   Outputs:  objtype, loadaddr, execaddr, length, attrib, filetype - the
  349.             desired file informations. If the file doesn't exist, objtype=0
  350.             and the other informations are meaningless; no error is
  351.             returned
  352.   Returns:  NULL if no error, otherwise the error returned by RISC OS
  353.   Errors:   -
  354.   SeeAlso:  -
  355.  
  356.  */
  357.  
  358.  
  359.  
  360.   void    Desk_Filing_SingleDirEntry( const char *filename,
  361.                                    Desk_filing_direntry *buf, int size);
  362. /*
  363.  
  364.   Purpose:  Reads a single directory entry. This function uses
  365.             Desk_Filing_ReadDirEntry() to read the file informations from its
  366.             directory.
  367.   Inputs:   filename - the file pathname
  368.             buf - pointer to a buffer where the content will be stored
  369.             size - the length of the buffer
  370.   Outputs:  -
  371.   Returns:  NULL if no error, otherwise the error.
  372.             If the file doesn't exist (but its pathname exists!) no error
  373.             will be returned but objtype in the Desk_filing_fulldirentry structure
  374.             will be set to 0.
  375.             If the pathname is illegal or some directory in this path doesn't
  376.             exist an error will be returned.
  377.   Errors:   Every possible error returned by RISC OS
  378.   SeeAlso:  Desk_filing_direntry; Desk_Filing_ReadDirEntry;
  379.             Desk_Filing_SingleDirEntry2; Desk_Filing_SingleFullDirEntry;
  380.  
  381.  */
  382.  
  383.  
  384.  
  385.  void    Desk_Filing_SingleDirEntry2( const char *dirname,
  386.                                    Desk_filing_direntry *buf,
  387.                                    int size, const char *filename);
  388. /*
  389.  
  390.   Purpose:  Reads a single directory entry (dirname and filename splitted).
  391.             This function uses Desk_Filing_ReadDirEntry() to read the file
  392.             informations from its directory.
  393.   Inputs:   dirname - the directory pathname
  394.             buf - pointer to a buffer where the content will be stored
  395.             size - the length of the buffer
  396.             filename - the filename (only the leafname!)
  397.   Outputs:  -
  398.   Returns:  NULL if no error, otherwise the error.
  399.             If the file doesn't exist (but the pathname exists!) no error
  400.             will be returned but objtype in the Desk_filing_fulldirentry structure
  401.             will be set to 0.
  402.             If the pathname is illegal or some directory in it doesn't exist
  403.             an error will be returned.
  404.   Errors:   -
  405.   SeeAlso:  Desk_filing_direntry; Desk_Filing_ReadDirEntry;
  406.             Desk_Filing_SingleDirEntry;
  407.  
  408.  */
  409.  
  410.  
  411.  
  412.   void    Desk_Filing_SingleFullDirEntry( const char *filename,
  413.                                        Desk_filing_fulldirentry *buf, int size);
  414. /*
  415.  
  416.   Purpose:  Reads a single directory entry (full info version). This
  417.             function uses Desk_Filing_ReadFullDirEntry() to read the (full) file
  418.             informations from its directory. This is (for what I know!) the
  419.             only way to read the SIN of a single file.
  420.   Inputs:   filename - the file pathname
  421.             buf - pointer to a buffer where the content will be stored
  422.             size - the length of the buffer
  423.   Outputs:  -
  424.   Returns:  NULL if no error, otherwise the error.
  425.             If the file doesn't exist (but its pathname exists!) no error
  426.             will be returned but objtype in the Desk_filing_fulldirentry structure
  427.             will be set to 0.
  428.             If the pathname is illegal or some directory in this path doesn't
  429.             exist an error will be returned.
  430.   Errors:   Every possible error returned by RISC OS
  431.   SeeAlso:  Desk_filing_fulldirentry; Desk_Filing_ReadFullDirEntry;
  432.             Desk_Filing_SingleFullDirEntry2; Desk_Filing_SingleDirEntry;
  433.  
  434.  */
  435.  
  436.  
  437.  
  438.  void    Desk_Filing_SingleFullDirEntry2( const char *dirname,
  439.                                        Desk_filing_fulldirentry *buf,
  440.                                        int size, const char *filename);
  441. /*
  442.  
  443.   Purpose:  Reads a single directory entry (full info version, dirname and
  444.             filename splitted). This function uses Desk_Filing_ReadFullDirEntry()
  445.             to read the (full) file informations from its directory. This is
  446.             (for what I know!) the only way to read the SIN of a single file.
  447.   Inputs:   dirname - the directory pathname
  448.             buf - pointer to a buffer where the content will be stored
  449.             size - the length of the buffer
  450.             filename - the filename (only the leafname!)
  451.   Outputs:  -
  452.   Returns:  NULL if no error, otherwise the error.
  453.             If the file doesn't exist (but the pathname exists!) no error
  454.             will be returned but objtype in the Desk_filing_fulldirentry structure
  455.             will be set to 0.
  456.             If the pathname is illegal or some directory in it doesn't exist
  457.             an error will be returned.
  458.   Errors:   -
  459.   SeeAlso:  Desk_filing_fulldirentry; Desk_Filing_ReadFullDirEntry;
  460.             Desk_Filing_SingleFullDirEntry;
  461.  
  462. */
  463.  
  464.  
  465.  
  466.  
  467.   char *Desk_Filing_GetPathname( const char *filename, char *pathname);
  468. /*
  469.  
  470.   Purpose:  Gets the pathname from a filename (ie. strips out the leafname)
  471.   Inputs:   filename - the filename. If this is a NULL pointer nothing will
  472.                        happen
  473.             pathname - the string that will contain the pathname. If this is
  474.                        a NULL pointer nothing will happen
  475.   Outputs:  pathname - the pathname. If filename is a leafname (ie. no '.'s
  476.                        in it) pathname will be an empty string
  477.   Returns:  pathname
  478.   Errors:   -
  479.   SeeAlso:  Desk_Filing_GetLeafname; Desk_Filing_FindLeafname;
  480.  
  481.  */
  482.  
  483.  
  484.  
  485.  
  486.  
  487.   char *Desk_Filing_GetLeafname( const char *filename, char *leafname);
  488. /*
  489.  
  490.   Purpose:  Gets the leafname from a filename (ie. strips out the path)
  491.   Inputs:   filename - the filename. If this is a NULL pointer nothing will
  492.                        happen
  493.             leafname - the string that will contain the pathname. If this is
  494.                        a NULL pointer nothing will happen
  495.   Outputs:  leafname - the leafname. If filename is just a leafname itself
  496.                        (ie. no '.'s in it) leafname will be the same as
  497.                        filename
  498.   Returns:  leafname
  499.   Errors:   -
  500.   SeeAlso:  Desk_Filing_FindLeafname; Desk_Filing_GetPathname;
  501.  
  502.  */
  503.  
  504.  
  505.  
  506.   char *Desk_Filing_FindLeafname( const char *filename);
  507. /*
  508.  
  509.   Purpose:  Finds the leafname inside a full pathname
  510.   Inputs:   filename - the filename. If this is a NULL pointer nothing will
  511.                        happen
  512.   Outputs:  -
  513.   Returns:  a pointer to the leafname (this pointer will be inside filename).
  514.             If filename is just a leafname (ie. no '.'s in it) the returned
  515.             value will be filename itself
  516.   Errors:   -
  517.   SeeAlso:  Desk_Filing_GetLeafname; Desk_Filing_GetPathname;
  518.  
  519.  */
  520.  
  521.  
  522.  
  523.   char *Desk_Filing_MakePath( char *newpath, const char *dirname, const char *leafname);
  524. /*
  525.  
  526.   Purpose:  Constructs the full pathname from the directory and leafname
  527.   Inputs:   newpath - the string that will contain the full pathname
  528.             dirname - the directory name
  529.             leafname - the file leafname
  530.   Outputs:  newpath - the desired full pathname (ie. dirname+'.'+leafname)
  531.   Returns:  newpath
  532.   Errors:   -
  533.   SeeAlso:  -
  534.  
  535.  */
  536.  
  537.  
  538.  
  539.   void    Desk_Filing_CanonicalisePath( const char *pathname, char *buffer,
  540.                                      int size, int *spare);
  541. /*
  542.  
  543.   Purpose:  Converts a pathname to a canonicalised path
  544.             (veneer for SWI Desk_OS_FSControl 37)
  545.   Inputs:   pathname - the pathname to convert
  546.             buffer - pointer to the buffer where the canonicalised path
  547.                      will be stored
  548.             size - the length of the buffer
  549.   Outputs:  spare - the number of spare bytes in the buffer
  550.   Returns:  
  551.   Errors:   -
  552.   SeeAlso:  -
  553.  
  554.  */
  555.  
  556.  
  557.  
  558.   typedef Desk_os_error *(*Desk_filing_scan_startdirfn) ( const char *dirname,
  559.                                                 Desk_filing_fulldirentry *dirdata,
  560.                                                 void *reference);
  561. /*
  562.  
  563.   Purpose:  The type of functions that are called by Desk_Filing_ScanDir (and
  564.             similar functions) every time a new directory is scanned.
  565.             If this functions returns a non-NULL pointer the scan will be
  566.             aborted and Desk_Filing_ScanDir will return this error. If it returns
  567.             Desk_filing_scan_PRUNE, the scan will skip the directory.
  568.   Fields:   dirname   - the directory name
  569.             dirdata   - the data of the directory (only if available, see
  570.                         Desk_Filing_ScanDir and similar functions)
  571.             reference - as passed to Desk_Filing_ScanDir.
  572.   SeeAlso:  Desk_Filing_ScanDir;
  573.  
  574.  */
  575.  
  576.  
  577.  
  578.   typedef Desk_os_error *(*Desk_filing_scan_foundfilefn) ( const char *dirname,
  579.                                                  Desk_filing_fulldirentry *filedata,
  580.                                                  void *reference);
  581. /*
  582.  
  583.   Purpose:  The type of functions that are called by Desk_Filing_ScanDir (and
  584.             similar functions) at every file. If this functions returns a
  585.             non-NULL pointer the scan will be aborted and Desk_Filing_ScanDir
  586.             will return this error.
  587.   Fields:   dirname - the directory name
  588.             filedata  - the data of the current file inside the directory
  589.             reference - as passed to Desk_Filing_ScanDir.
  590.   SeeAlso:  Desk_Filing_ScanDir;
  591.  
  592.  */
  593.  
  594.  
  595.  
  596.   typedef Desk_os_error *(*Desk_filing_scan_enddirfn) ( const char *dirname,
  597.                                               Desk_filing_fulldirentry *dirdata, 
  598.                                               void *reference);
  599. /*
  600.  
  601.   Purpose:  The type of functions that are called by Desk_Filing_ScanDir (and
  602.             similar functions) every time the scan of the directory is
  603.             finished. If this functions returns a non-NULL pointer the scan
  604.             will be aborted and Desk_Filing_ScanDir will return this error.
  605.   Fields:   dirname   - the directory name
  606.             dirdata   - the data of the directory (only if available, see
  607.                         Desk_Filing_ScanDir and similar functions)
  608.             reference - as passed to Desk_Filing_ScanDir.
  609.   SeeAlso:  Desk_Filing_ScanDir;
  610.  
  611.  */
  612.  
  613.  
  614.  
  615.  
  616. #define    Desk_filing_scan_PRUNE    ( (Desk_os_error *) 1)
  617. /*
  618. A Desk_filing_scan_startdirfn should return this if the scan should go no
  619. deeper.
  620.  */
  621.  
  622.   void    Desk_Filing_ScanDir( const char *dirname,
  623.                             Desk_filing_scan_startdirfn startdirproc,
  624.                             Desk_filing_scan_foundfilefn foundfileproc,
  625.                             Desk_filing_scan_enddirfn enddirproc,
  626.                             void *reference
  627.                             );
  628. /*
  629.  
  630.   Purpose:  Scans a directory tree calling the specified functions.
  631.             This function is reentrant: you can call it from one of the
  632.             functions it calls.
  633.             Subdirectories may be scanned before the parent directory has
  634.             been completely scanned, hence 'startdirproc' may be called more
  635.             than once before the corresponding 'enddirproc' is called.
  636.             If you need to end the scan of a directory before starting the
  637.             scan of a new one you can use Desk_Filing_ScanDirByDir.
  638.   Inputs:   dirname - the directory name where the scan will start
  639.             startdirproc - the function called every time a new directory
  640.                            is started, including the one specified by
  641.                            'dirname' (ie. before the files contained in it
  642.                            are scanned). If this is NULL, no function will
  643.                            be called.
  644.             foundfileproc - the function called every time a new file is
  645.                             found (including directories). If this is NULL,
  646.                             no function will be called.
  647.             enddirproc - the function called every time a directory scan
  648.                          ends (ie. after all the files contained in it
  649.                          have been scanned). If this is NULL, no function
  650.                          will be called.
  651.             reference - This is passed to the three functions startdirproc,
  652.                         foundfileproc, enddirproc.
  653.   Outputs:  -
  654.   Returns:  NULL if no error, otherwise the error (generated by RISC OS
  655.             during the scan or returned by a function)
  656.   Errors:   -
  657.   SeeAlso:  Desk_Filing_ScanDir_StartDir; Desk_Filing_ScanDir_FoundFile;
  658.             Desk_Filing_ScanDir_EndDir; Desk_Filing_ScanDirByDir;
  659.  
  660.  */
  661.  
  662.  
  663.  
  664.   void    Desk_Filing_ScanDirByDir( const char *dirname,
  665.                             Desk_filing_scan_startdirfn startdirproc,
  666.                             Desk_filing_scan_foundfilefn foundfileproc,
  667.                             Desk_filing_scan_enddirfn enddirproc,
  668.                             void *reference
  669.                             );
  670. /*
  671.  
  672.   Purpose:  Scans a directory tree calling the specified functions.
  673.             This function is reentrant: you can call it from one of the
  674.             functions it calls.
  675.             When a directory is scanned, 'startdirproc' is called, then
  676.             'foundfileproc' is called for every file (including directories)
  677.             contained in it and then 'enddirproc' is called. Finally, if the
  678.             directory contained some subdirectory, they will be scanned.
  679.             If you only need to scan directories and subdirectories in no
  680.             particular order, see Desk_Filing_ScanDir since it is faster.
  681.             Unlike Desk_Filing_Scandir, it is easy to prevent Desk_Filing_ScanDirByDir
  682.             from recursively scan subdirectories: you should just return an
  683.             error (eg (Desk_os_error *)-1) from 'enddirproc' so that only the
  684.             files in the first directory will be scanned and then the error
  685.             will be returned.
  686.   Inputs:   dirname - the directory name where the scan will start
  687.             startdirproc - the function called every time a new directory
  688.                            is started, including the one specified by
  689.                            'dirname' (ie. before the files contained in it
  690.                            are scanned). If this is NULL, no function will
  691.                            be called.
  692.             foundfileproc - the function called every time a new file is
  693.                             found (including directories). If this is NULL,
  694.                             no function will be called.
  695.             enddirproc - the function called every time a directory scan
  696.                          ends (ie. after all the files contained in it
  697.                          have been scanned). If this is NULL, no function
  698.                          will be called.
  699.             reference - This is passed to the three functions startdirproc,
  700.                         foundfileproc, enddirproc.
  701.   Outputs:  -
  702.   Returns:  NULL if no error, otherwise the error (generated by RISC OS
  703.             during the scan or returned by a function)
  704.   Errors:   -
  705.   SeeAlso:  Desk_Filing_ScanDir_StartDir; Desk_Filing_ScanDir_FoundFile;
  706.             Desk_Filing_ScanDir_EndDir; Desk_Filing_ScanDir;
  707.  
  708.  */
  709.  
  710.  
  711.  
  712. int    Desk_Filing_CompareDates( char date1[5], char date2[5]);
  713. /*
  714. Purpose:    Compares two 5-byte dates as used in file date-stamps.
  715. Inputs:        Pointers to two 5-char arrays, eg the 'date' fields
  716.         from two Desk_filing_fulldirentry structures, or the 
  717.         'fivebytedate' array filled-in by Desk_File_Date.
  718. Returns:    +1 if date1 is later than date2.
  719.         -1 if date1 is earlier than date2.
  720.          0 if date1 equals date2.
  721. */
  722.  
  723.  
  724.  
  725. #ifdef __cplusplus
  726. }
  727. #endif
  728.  
  729. #endif
  730.