home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 18.3 Unprotect()
- Author: Joe Booth
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- #include "FILEIO.CH"
-
- function unprotect(file_name)
- LOCAL handle,first_byte,buffer:=" "
- LOCAL fn:=trim(file_name)
- if (handle := Fopen(fn+".DBF",FO_READWRITE)) > -1
- fread(handle,@buffer,1) // Read first byte
- first_byte := asc(buffer)
- fseek(handle,0,0) // Go to top of file
- if first_byte = 27 // Is a memo file needed?
- fwrite(handle,chr(131),1)
- else
- fwrite(handle,chr(03),1)
- endif
- fclose(handle) // Close the file
- endif
- return NIL
-
- // end of file CHP1803.PRG
-