Пример #1
0
	LFA_FileRef FileInfo::Decompress()
	{

		if ( ! this->IsCompressed() ) return this->fileRef;
		
		LFA_FileRef updateRef = 0;
		std::string updatePath;

		try {

			CreateTempFile ( this->origFilePath, &updatePath, kCopyMacRsrc );
			updateRef = LFA_Open ( updatePath.c_str(), 'w' );
			this->tmpFilePath.assign ( updatePath );

			int ret = this->Encode ( this->fileRef, updateRef, FWS, Inf );
			this->tmpFileRef = updateRef;
			if ( ret != Z_OK ) XMP_Throw ( "zstream error occured", kXMPErr_ExternalFailure );

			return this->tmpFileRef;

		} catch ( ... ) {

			LFA_Close ( updateRef );
			LFA_Delete ( updatePath.c_str() );
			return this->fileRef;

		}

	}	// FileInfo::Decompress
Пример #2
0
	LFA_FileRef LFA_Create ( const char * filePath )
	{
		// *** Hack: Use fopen to avoid parent/child name separation needed by FSCreateFileUnicode.

		if ( FileExists ( filePath ) ) {
			LFA_Throw ( "LFA_Create: file already exists", kLFAErr_ExternalFailure );
		}

		FILE * temp = fopen ( filePath, "w" );
		if ( temp == 0 ) LFA_Throw ( "LFA_Create: fopen failure", kLFAErr_ExternalFailure );
		fclose ( temp );

		return LFA_Open ( filePath, 'w' );

	}	// LFA_Create