home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
datafiles
/
text
/
c_manual
/
system
/
amigados
/
example6.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-27
|
2KB
|
76 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) V3.0 Amiga C Club (ACC) */
/* ------------------------------- ------------------ */
/* */
/* Book: ACM System Amiga C Club */
/* Chapter: AmigaDOS Tulevagen 22 */
/* File: Example6.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 92-05-02 */
/* Version: 1.10 */
/* */
/* Copyright 1992, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This example demonstrates how to protect and unprotect files. */
/* The file Example 5 created ("Letter.doc") will be protected, */
/* and we will then try to delete it (unsuccessfully). We will */
/* then unprotect the file and then try to delete it */
/* (successfully). */
/* Declares BOOL: */
#include <exec/types.h>
/* Declares the FileHandle structure: */
#include <libraries/dos.h>
void main();
void main()
{
BOOL ok;
/* Protect the file: */
ok = SetProtection( "RAM:Letter.doc", FIBF_DELETE );
/* Check if the file was successfully protected: */
if( !ok )
printf( "Could not protect the file!\n" );
/* Try to delete the file: */
ok = DeleteFile( "RAM:Letter.doc" );
/* Check if the file was successfully deleteted: */
if( !ok )
printf( "Could not delete the file!\n" );
else
printf( "File deleted!\n" );
/* Unprotect the file: */
ok = SetProtection( "RAM:Letter.doc", NULL );
/* Check if the file was successfully unprotected: */
if( !ok )
printf( "Could not unprotect the file!\n" );
/* Try to delete the file: */
ok = DeleteFile( "RAM:Letter.doc" );
/* Check if the file was successfully deleteted: */
if( !ok )
printf( "Could not delete the file!\n" );
else
printf( "File deleted!\n" );
}