183 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			183 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //
 | |
| // ATTRDOS.CPP
 | |
| //
 | |
| //  Source file for ArchiveLib 2.0
 | |
| //
 | |
| //  Copyright (c) Greenleaf Software, Inc. 1994-1996
 | |
| //  All Rights Reserved
 | |
| //
 | |
| // CONTENTS
 | |
| //
 | |
| //  ALFile::ReadAttributesFromFileSys()
 | |
| //  ALFile::WriteAttributesToFileSys()
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  These two files provide system-dependent functionality for ALFile.
 | |
| //  It takes different code to set the attributes for files depending
 | |
| //  on which O/S you are targetting.
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release
 | |
| 
 | |
| #include "arclib.h"
 | |
| #if !defined( AL_IBM )
 | |
| #pragma hdrstop
 | |
| #endif
 | |
| 
 | |
| #include <dos.h>
 | |
| #include "filestor.h"
 | |
| 
 | |
| //
 | |
| // NAME
 | |
| //
 | |
| //  ALFile::ReadAttributesFromFileSys()
 | |
| //
 | |
| // PLATFORMS/ENVIRONMENTS
 | |
| //
 | |
| //  MS-DOS Win16
 | |
| //  C++
 | |
| //
 | |
| // SHORT DESCRIPTION
 | |
| //
 | |
| //  Read in the attributes of a file under MS-DOS.
 | |
| //
 | |
| // C++ SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //  #include "filestor.h"
 | |
| //
 | |
| //  int ALFile::ReadAttributesFromFileSys();
 | |
| //
 | |
| // C SYNOPSIS
 | |
| //
 | |
| //  None, this internal protected function has no C version.
 | |
| //
 | |
| // VB SYNOPSIS
 | |
| //
 | |
| //  None, this internal protected function has no VB version.
 | |
| //
 | |
| // DELPHI SYNOPSIS
 | |
| //
 | |
| //  None, this internal protected function has no Delphi version.
 | |
| //
 | |
| // ARGUMENTS
 | |
| //
 | |
| //  None.
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  When an ALFile object is opened, we have to read the file attributes.
 | |
| //  This is an O/S dependent function, but I don't want to have too many
 | |
| //  #ifdefs, so I package it in a separate directory that gets compiled
 | |
| //  in an environment dependent fashion.  This particular file gets
 | |
| //  compiled for any library that's using the MS-DOS file system.
 | |
| //
 | |
| //  All this function has to do is call the _dos_getfileattattr() function,
 | |
| //  then translate the returned bits into the appropriate internal attribute
 | |
| //  bits.
 | |
| //
 | |
| // RETURNS
 | |
| //
 | |
| //  AL_SUCCESS or AL_CANT_OPEN_FILE.
 | |
| //
 | |
| // EXAMPLE
 | |
| //
 | |
| // SEE ALSO
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release.
 | |
| //
 | |
| 
 | |
| int AL_PROTO
 | |
| ALFile::ReadAttributesFromFileSys()  /* Tag protected function */
 | |
| {
 | |
|     unsigned attributes;
 | |
|     if ( _dos_getfileattr( mName, &attributes ) != 0 )
 | |
|         return AL_CANT_OPEN_FILE;
 | |
|     mAttributes.miUnixBitsPresent = 0;
 | |
|     mAttributes.miReadOnly = ( attributes & _A_RDONLY ) != 0;
 | |
|     mAttributes.miSystem = ( attributes & _A_SYSTEM ) != 0;
 | |
|     mAttributes.miHidden = ( attributes & _A_HIDDEN ) != 0;
 | |
|     mAttributes.miArchive = ( attributes & _A_ARCH ) != 0;
 | |
|     return AL_SUCCESS;
 | |
| }
 | |
| 
 | |
| //
 | |
| // NAME
 | |
| //
 | |
| //  ALFile::WriteAttributesToFileSys()
 | |
| //
 | |
| // PLATFORMS/ENVIRONMENTS
 | |
| //
 | |
| //  MS-DOS Win16
 | |
| //  C++
 | |
| //
 | |
| // SHORT DESCRIPTION
 | |
| //
 | |
| //  Set the attributes of a file under MS-DOS.
 | |
| //
 | |
| // C++ SYNOPSIS
 | |
| //
 | |
| //  #include "arclib.h"
 | |
| //  #include "filestor.h"
 | |
| //
 | |
| //  int ALFile::WriteAttributesToFileSys();
 | |
| //
 | |
| // C SYNOPSIS
 | |
| //
 | |
| //  None, this internal protected function has no C version.
 | |
| //
 | |
| // VB SYNOPSIS
 | |
| //
 | |
| //  None, this internal protected function has no VB version.
 | |
| //
 | |
| // DELPHI SYNOPSIS
 | |
| //
 | |
| //  None, this internal protected function has no Delphi version.
 | |
| //
 | |
| // ARGUMENTS
 | |
| //
 | |
| //  None.
 | |
| //
 | |
| // DESCRIPTION
 | |
| //
 | |
| //  When an ALFile object is closed, we have to set the file attributes.
 | |
| //  This is an O/S dependent function, but I don't want to have too many
 | |
| //  #ifdefs, so I package it in a separate directory that gets compiled
 | |
| //  in an environment dependent fashion.  This particular file gets
 | |
| //  compiled for any library that's using the MS-DOS file system.
 | |
| //
 | |
| //  All this function has to do is call the _dos_setfileattattr() function,
 | |
| //  with the appopriate bits set.  This means I have to translate the
 | |
| //  internal bits into the format expected by the DOS API.
 | |
| //
 | |
| // RETURNS
 | |
| //
 | |
| //  Nothing.
 | |
| //
 | |
| // EXAMPLE
 | |
| //
 | |
| // SEE ALSO
 | |
| //
 | |
| // REVISION HISTORY
 | |
| //
 | |
| //   February 14, 1996  2.0A : New release.
 | |
| //
 | |
| 
 | |
| void AL_PROTO
 | |
| ALFile::WriteAttributesToFileSys()  /* Tag protected function */
 | |
| {
 | |
|     unsigned int attributes = 0;
 | |
|     if ( !mAttributes.miUnixBitsPresent ) {
 | |
|         attributes |= mAttributes.miReadOnly ? _A_RDONLY : 0;
 | |
|         attributes |= mAttributes.miSystem ? _A_SYSTEM : 0;
 | |
|         attributes |= mAttributes.miHidden ? _A_HIDDEN : 0;
 | |
|         attributes |= mAttributes.miArchive ? _A_ARCH : 0;
 | |
|         _dos_setfileattr( mName, attributes );
 | |
|     }
 | |
| }
 | |
| 
 |