Page 1 of 1

Setting the archive bit / Tracking "processed" files

Posted: Mon Mar 01, 2010 11:45 pm
by xProgrammer
Hi all

I need to write an application that checks for any "new" files in a directory and then processes them. One possibility is to use the date and time stamp of the file and keep a record of when the scan for new files was last done.

I was thinking that a better way might be to use the archive bit - as files are processed set the archive bit. I can get the archive bit OK with FileAttr(), and Directory() but how about setting the archive bit?

If I can set the archive bit then maybe I should try to modify Directory() to take an additional attribute for returning only files without the archive bit set to achieve what I want.

Regards
xProgrammer

Re: Setting the archive bit / Tracking "processed" files

Posted: Tue Mar 02, 2010 1:57 am
by hua
Hi Doug,
>I can get the archive bit OK with FileAttr(), and Directory() but how about setting the archive bit?

Maybe SetFAttr()? It's in ct.lib in xHarbour.
SetFAttr()
Sets file attributes.

Syntax
SetFAttr( <cFileName>, [<nAttributes>] ) --> nErrorCode

Arguments
<cFileName>
This is a character string holding the name of the file to set attributes for. It must include path and file extension. If the path is omitted from <cFileName>, the file is searched in the current directory only.

<nAttributes>
This is a numeric value specifying the file attributes to set. Values of the following list are used for file attributes. To specifiy multiple attributes, pass the sum of the corresponding values:
Values for file attributes
  • 0 - Normal
    1 - Read only
    2 - Hidden
    4 - System
    8 - Volume
    32 - Archived
Return
The function returns zero on success or a numeric error code on failure.

Re: Setting the archive bit / Tracking "processed" files

Posted: Tue Mar 02, 2010 6:07 am
by xProgrammer
Thanks Hua

Somehow I didn't see SetFAttr() despite looking.

Regards
(a slightly embarrassed) xProgrammer