Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Proclip2 Library - <b> fileattr() </b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 FILEATTR() 

          If you have clients who like to tinker too much, this function can
          be invaluable.  Employing this function properly it is now
          extremely easy to "lock" a file where the average user cannot
          inadvertently damage it.

          The FILEATTR function allows setting or resetting the directory
          attributes of a given file.  Attributes available are read-only,
          archive, hidden and system.  Prudent use of the read-only and/or
          hidden attribute can protect your databases from prying eyes.  To
          reaccess the database simply have your application remove the
          necessary flags prior to use, it's that easy.


      Format: 

               fileattr(filename,fileattr)


      Parameters: 

               filename..Character string variable or constant, non case
                         sensitive, which contains the filename whose
                         attributes you wish to change.  The filename should
                         follow the standard [drive:][\path\]filename format
                         where drive and path are optional.  Wildcards (* &
                         ?) are not allowed in the filename.

               fileattr..Character string variable or constant, non case
                         sensitive, which provides the function with a list
                         of all attributes to set or reset.

                         + (plus sign)  An attribute proceeded by a plus sign
                                        (+) instructs the function to set
                                        this flag in the directory entry for
                                        this file.

                         - (minus sign) An attribute proceeded by a minus
                                        sign (-) instructs the function to
                                        clear this flag in the directory
                                        entry for this file.

                          NOTE:          Although not advisable, it is
                                        possible to place an activate (+) and
                                        deactivate (-) for the same flag in
                                        the attribute string (eg. '+r/o -arc
                                        -r/o').  The last flag encountered in
                                        a left to right scan will be the
                                        action taken.  In this example the
                                        file would have the read-only and
                                        archive cleared (not set), the '+r/o'
                                        would have no effect.

                                  (valid file attributes)

                              r/o                 Read only
                              hid                 Hidden
                              sys                 System
                              arc                 Archive


      Examples: 

               1.   Suppose you have "dangerous" clients who are constantly
                    fiddling with your files and inadvertently deleting them
                    from time to time.  In order to prevent this your
                    application could set the "read-only" attribute prior to
                    terminating.  To access the files again the application
                    could reset the "read-only" attribute when starting up.

                    (program start)
                    .
                    .
                    fileattr('CLIENT.DBF','-r/o')
                    .
                    (program executes)
                    .
                    fileattr('CLIENT.DBF','+r/o')
                    .
                    .
                    (program ends)

               1.   Combined with the DIR function, do the above example
                    through all existing files in the subdirectory.

                    (program starts)
                    .
                    .
                    filename = DIR('*.*','first')
                    do while .not. empty(filename)
                         fileattr(filename,'-r/o')
                         filename = DIR('next')
                    enddo
                    .
                    (program executes)
                    .
                    filename = DIR('*.*','first')
                    do while .not. empty(filename)
                         fileattr(filename,'+r/o')
                         filename = DIR('next')
                    enddo
                    .
                    (program ends)


      Returns: 

               .T.  .....Logical true (.T.) to indicate success of function.
                         Setting or resetting attributes which have already
                         been set or reset will still return a success flag.

               .F.  .....Logical false (.F.) to indicate failure of the
                         function.


      Cautions: 

               In order to assume proper operation, all files should be
               closed which may be accessed by the function.


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson