本文整理汇总了C++中KFileRelease函数的典型用法代码示例。如果您正苦于以下问题:C++ KFileRelease函数的具体用法?C++ KFileRelease怎么用?C++ KFileRelease使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KFileRelease函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vds_diff
rc_t vds_diff( const char * f1, const char * f2 )
{
KDirectory * dir;
rc_t rc = KDirectoryNativeDir( &dir );
if ( rc != 0 )
KOutMsg( "KDirectoryNativeDir() failed\n" );
else
{
const KFile * kf1;
rc = KDirectoryOpenFileRead ( dir, &kf1, "%s", f1 );
if ( rc != 0 )
KOutMsg( "cannot open file '%s'\n", f1 );
else
{
const KFile * kf2;
rc = KDirectoryOpenFileRead ( dir, &kf2, "%s", f2 );
if ( rc != 0 )
KOutMsg( "cannot open file '%s'\n", f2 );
else
{
rc = vds_diff_files( kf1, kf2 );
KFileRelease( kf2 );
}
KFileRelease( kf1 );
}
KDirectoryRelease( dir );
}
clear_recorded_errors();
return rc;
}
示例2: KLoaderFile_Open
static
rc_t KLoaderFile_Open(KLoaderFile* self)
{
rc_t rc = 0;
DBG(("%s opening %s\n", __func__, self->realname));
if( (rc = KDirectoryOpenFileRead(self->dir, &self->kfile, "%s", self->realname)) == 0 ) {
if( self->has_md5 ) {
const KFile *md5File = NULL;
DBG(("%s opening as md5 wrapped %s\n", __func__, self->realname));
if( (rc = KFileMakeMD5Read(&md5File, self->file, self->md5_digest)) == 0) {
self->file = md5File;
}
}
if( rc == 0 ) {
const KFile *z = NULL;
switch(self->compress_type) {
case compress_none:
break;
case compress_gzip:
DBG(("%s opening as gzip wrapped %s\n", __func__, self->realname));
if( (rc = KFileMakeGzipForRead(&z, self->file)) == 0 ) {
KFileRelease(self->file);
self->file = z;
}
break;
case compress_bzip2:
DBG(("%s opening as bzip2 wrapped %s\n", __func__, self->realname));
if( (rc = KFileMakeBzip2ForRead(&z, self->file)) == 0 ) {
KFileRelease(self->file);
self->file = z;
}
break;
default:
rc = RC(rcApp, rcFile, rcOpening, rcType, rcUnexpected);
break;
}
#if ! WINDOWS
if( rc == 0 && self->ahead ) {
const KFile *z = NULL;
if( (rc = KQueueFileMakeRead(&z, self->pos, self->file,
self->buffer_size * 10, self->buffer_size, 0)) == 0 ) {
KFileRelease(self->file);
self->file = z;
}
}
#endif
}
}
if( rc != 0 ) {
PLOGERR(klogErr, (klogErr, rc, "opening $(file)", PLOG_S(file), self->filename));
KFileRelease(self->file);
}
return rc;
}
示例3: make_lookup_reader
rc_t make_lookup_reader( const KDirectory *dir, const struct index_reader * index,
struct lookup_reader ** reader, size_t buf_size, const char * fmt, ... )
{
rc_t rc;
const struct KFile * f = NULL;
va_list args;
va_start ( args, fmt );
rc = KDirectoryVOpenFileRead( dir, &f, fmt, args );
if ( rc != 0 )
{
char tmp[ 4096 ];
size_t num_writ;
rc_t rc1 = string_vprintf( tmp, sizeof tmp, &num_writ, fmt, args );
if ( rc1 != 0 )
ErrMsg( "make_lookup_reader.KDirectoryVOpenFileRead( '?' ) -> %R", rc );
else
ErrMsg( "make_lookup_reader.KDirectoryVOpenFileRead( '%s' ) -> %R", tmp, rc );
}
else
{
const struct KFile * temp_file = NULL;
rc = KBufFileMakeRead( &temp_file, f, buf_size );
KFileRelease( f );
if ( rc != 0 )
{
ErrMsg( "make_lookup_reader.KBufFileMakeRead() -> %R", rc );
}
else
{
lookup_reader * r = calloc( 1, sizeof * r );
if ( r == NULL )
{
KFileRelease( temp_file );
rc = RC( rcVDB, rcNoTarg, rcConstructing, rcMemory, rcExhausted );
ErrMsg( "make_lookup_reader.calloc( %d ) -> %R", ( sizeof * r ), rc );
}
else
{
r->f = temp_file;
r->index = index;
rc = make_SBuffer( &r->buf, 4096 );
if ( rc == 0 )
*reader = r;
else
release_lookup_reader( r );
}
}
}
va_end ( args );
return rc;
}
示例4: ArchiveAndEncrypt
rc_t ArchiveAndEncrypt(KDirectory* wd, const char* inpath, const char* outpath, const char* passwd)
{
const KDirectory* d;
rc_t rc = KDirectoryOpenDirRead (wd, &d, false, "%s", inpath);
if (rc == 0)
{
const KFile* infile;
rc_t rc2;
rc = KDirectoryOpenTocFileRead (d, &infile, 4, NULL, NULL, NULL);
if (rc == 0)
{
KFile* outfile;
/* if the file exists, add write access */
KDirectorySetAccess( wd, false, 0600, 0777, "%s", outpath );
rc = KDirectoryCreateFile(wd, &outfile, false, 0600, kcmCreate|kcmInit, "%s", outpath);
if ( rc == 0 )
{
KFile* enc_outfile;
KKey key;
rc = KKeyInitRead(&key, kkeyAES256, passwd, string_measure(passwd, NULL));
if ( rc == 0 )
rc = KEncFileMakeWrite(&enc_outfile, outfile, &key);
if (rc == 0)
rc = copy_file(infile, enc_outfile);
rc2 = KFileRelease(outfile);
if (rc == 0)
rc = rc2;
/* remove write access */
rc2 = KDirectorySetAccess( wd, false, 0400, 0777, "%s", outpath );
if (rc == 0)
rc = rc2;
rc2 = KFileRelease(enc_outfile);
if (rc == 0)
rc = rc2;
}
rc2 = KFileRelease(infile);
if (rc == 0)
rc = rc2;
}
rc2 = KDirectoryRelease(d);
if (rc == 0)
rc = rc2;
}
return rc;
}
示例5: make_rna_splice_log
struct rna_splice_log * make_rna_splice_log( const char * filename, const char * toolname )
{
struct rna_splice_log * res = NULL;
KDirectory * dir;
rc_t rc = KDirectoryNativeDir ( &dir );
if ( rc == 0 )
{
KFile * f;
rc = KDirectoryCreateFile ( dir, &f, false, 0664, kcmInit, "%s", filename );
if ( rc == 0 )
{
res = calloc( 1, sizeof * res );
if ( res != NULL )
{
res->log_file = f;
if ( toolname != NULL )
res->tool_name = string_dup_measure ( toolname, NULL );
}
else
KFileRelease ( f );
}
KDirectoryRelease ( dir );
}
return res;
}
示例6: KQueueFileWhackRead
/* Whack
*/
static
rc_t KQueueFileWhackRead ( KQueueFile *self )
{
void *b;
/* no more reading */
QFMSG ( "%s: sealing queue\n", __func__ );
KQueueSeal ( self -> q );
/* flush the queue */
QFMSG ( "%s: popping queue\n", __func__ );
while ( KQueuePop ( self -> q, & b, NULL ) == 0 )
{
QFMSG ( "%s: dousing a buffer\n", __func__ );
free ( b );
}
/* wait for thread to exit */
QFMSG ( "%s: waiting for bg thread to exit\n", __func__ );
KThreadWait ( self -> t, NULL );
/* tear it down */
QFMSG ( "%s: freeing object\n", __func__ );
free ( self -> b );
KThreadRelease ( self -> t );
KQueueRelease ( self -> q );
KFileRelease ( self -> f );
free ( self );
return 0;
}
示例7: WriteNamelistToFileByName
LIB_EXPORT rc_t CC WriteNamelistToFileByName( const VNamelist * namelist, const char * filename,
const char * delim )
{
rc_t rc;
if ( namelist == NULL || filename == NULL || delim == NULL )
rc = RC( rcFS, rcFile, rcValidating, rcParam, rcNull );
else
{
KDirectory * dir;
rc = KDirectoryNativeDir ( &dir );
if ( rc == 0 )
{
KFile * f;
rc = KDirectoryCreateFile ( dir, &f, true, 0664, kcmCreate, filename );
if ( rc == 0 )
{
if ( rc == 0 )
rc = SaveToFile( f, namelist, delim );
KFileRelease ( f );
}
KDirectoryRelease ( dir );
}
}
return rc;
}
示例8: LoadFileByNameToNameList
LIB_EXPORT rc_t CC LoadFileByNameToNameList( VNamelist * namelist, const char * filename )
{
rc_t rc;
if ( namelist == NULL || filename == NULL )
rc = RC( rcFS, rcFile, rcValidating, rcParam, rcNull );
else
{
KDirectory * dir;
rc = KDirectoryNativeDir ( &dir );
if ( rc == 0 )
{
KFile const * f;
rc = KDirectoryOpenFileRead ( dir, &f, "%s", filename );
if ( rc == 0 )
{
if ( rc == 0 )
rc = LoadFromFile( f, namelist );
KFileRelease ( f );
}
KDirectoryRelease ( dir );
}
}
return rc;
}
示例9: SpotIteratorDestroy
static rc_t SpotIteratorDestroy(struct SpotIterator* self)
{
assert(self);
KDirectoryRelease(__SpotIteratorDirectory);
__SpotIteratorDirectory = NULL;
return KFileRelease(self->m_file);
}
示例10: KMemBankWhack
/* Whack
*/
static
void KMemBankWhack ( KMemBank *self )
{
freeColdStorage(self->coldStorage, 0);
KFileRelease(self->pf);
free(self);
}
示例11: KColumnDataOpenRead
/* Open
*/
rc_t KColumnDataOpenRead ( KColumnData *self,
const KDirectory *dir, uint64_t eof, size_t pgsize )
{
rc_t rc = KDirectoryVOpenFileRead ( dir,
& self -> f, "data", NULL );
#if DATA_READ_FILE_BUFFER
if ( rc == 0 )
{
const KFile * orig = self -> f;
rc = KBufFileMakeRead ( & self -> f, self -> f, DATA_READ_FILE_BUFFER );
if ( rc == 0 )
{
KFileRelease ( orig );
}
else
{
self -> f = orig;
rc = 0;
}
}
#endif
if ( rc == 0 )
rc = KColumnDataInit ( self, eof, pgsize );
return rc;
}
示例12: KColumnIdx2Init
/* Init
*/
static
rc_t KColumnIdx2Init ( KColumnIdx2 *self, uint64_t idx2_eof )
{
rc_t rc;
#if 0
memset(&self->cstorage,0,sizeof(self->cstorage));
self->cstorage.elem_bits = sizeof(KColumnIdx2BlockCache)*8;
self->last = 0;
#endif
rc = KFileSize ( self -> f, & self -> eof );
if ( rc == 0 )
{
if ( self -> eof < idx2_eof )
rc = RC ( rcDB, rcColumn, rcConstructing, rcIndex, rcCorrupt );
else
{
self -> eof = idx2_eof;
return 0;
}
}
KFileRelease ( self -> f );
self -> f = NULL;
return rc;
}
示例13: CCFileDestroy
/* ----------------------------------------------------------------------
* Destroy
*
*/
static
rc_t CC CCFileDestroy (CCFile *self)
{
rc_t rc = KFileRelease (self->original);
free (self);
return rc;
}
示例14: KColumnDataWhack
/* Whack
*/
rc_t KColumnDataWhack ( KColumnData *self )
{
rc_t rc = KFileRelease ( self -> f );
if ( rc == 0 )
self -> f = NULL;
return rc;
}
示例15: whack_lane
static void whack_lane( lane * l )
{
/* KFileRelease( l->mappings ); */
KFileRelease( l->reads );
StringWhack ( l->name );
free( l );
}