T_BOOL Fwl_MoveFile(T_pCWSTR oldFile,T_pCWSTR newFile) { T_BOOL ret = AK_FALSE; T_hFILE source = 0; T_hFILE dest = 0; if (AK_NULL == oldFile || AK_NULL == newFile) { return AK_FALSE; } source = File_OpenUnicode((T_hFILE)AK_NULL, oldFile, FILE_MODE_READ); if (FS_INVALID_HANDLE == source) { return AK_FALSE; } dest = File_OpenUnicode((T_hFILE)AK_NULL, newFile, FILE_MODE_READ); if (FS_INVALID_HANDLE== dest) { File_Close(source); return AK_FALSE; } ret = File_RenameTo(source, dest); File_Close(source); File_Close(dest); return ret; }
int D88_SetFD(int drv, char* filename) { int trk, sct; FILEH fp; D88_SECTOR d88s; strncpy(D88File[drv], filename, MAX_PATH); D88File[drv][MAX_PATH-1] = 0; fp = File_Open(D88File[drv]); if ( !fp ) { ZeroMemory(D88File[drv], MAX_PATH); return FALSE; } File_Seek(fp, 0, FSEEK_SET); if ( File_Read(fp, &D88Head[drv], sizeof(D88_HEADER))!=sizeof(D88_HEADER) ) goto d88_set_error; if ( D88Head[drv].protect ) { FDD_SetReadOnly(drv); } for (trk=0; trk<164; trk++) { long ptr = D88Head[drv].trackp[trk]; D88_SECTINFO *si, *oldsi = NULL; if ( (ptr>=(long)sizeof(D88_HEADER))&&(ptr<D88Head[drv].fd_size) ) { d88s.sectors = 65535; File_Seek(fp, ptr, FSEEK_SET); for (sct=0; sct<d88s.sectors; sct++) { if ( File_Read(fp, &d88s, sizeof(D88_SECTOR))!=sizeof(D88_SECTOR) ) goto d88_set_error; si = (D88_SECTINFO*)malloc(sizeof(D88_SECTINFO)+d88s.size); if ( !si ) goto d88_set_error; if ( sct ) { oldsi->next = si; } else { D88Trks[drv][trk] = si; } memcpy(&si->sect, &d88s, sizeof(D88_SECTOR)); if ( File_Read(fp, ((unsigned char*)si)+sizeof(D88_SECTINFO), d88s.size)!=d88s.size ) goto d88_set_error; si->next = 0; if (oldsi) oldsi = si; } } } File_Close(fp); return TRUE; d88_set_error: File_Close(fp); FDD_SetReadOnly(drv); return FALSE; }
int RUCE_Roto_CtorLoad(RUCE_Roto* This, String* Path) { int Ret = 1; File RotoFile; String RotoContent; String_Ctor(& RotoContent); File_Ctor(& RotoFile); if(! File_Open(& RotoFile, Path, READONLY)) { Ret = 0; goto End; } File_Read_String(& RotoFile, & RotoContent); This -> Ptr = cJSON_Parse(String_GetChars(& RotoContent)); if(! This -> Ptr) Ret = 0; End: File_Close(& RotoFile); File_Dtor(& RotoFile); String_Dtor(& RotoContent); RInit(RUCE_Roto); return Ret; }
T_BOOL Fwl_FileExist(T_pCWSTR path) { T_hFILE pFile = 0; T_BOOL ret = AK_FALSE; if (AK_NULL != path) { pFile = File_OpenUnicode((T_hFILE)AK_NULL, path, FILE_MODE_READ); if (FS_INVALID_HANDLE == pFile) { pFile = File_OpenUnicode((T_hFILE)AK_NULL, path, FILE_MODE_ASYN | FILE_MODE_READ); if (FS_INVALID_HANDLE == pFile) { //AK_DEBUG_OUTPUT("FWL FILE ERROR: Fwl_FileExist:open fail %d\n", pFile); return AK_FALSE; } } ret = File_Exist(pFile); File_Close(pFile); } return ret; }
int MIDI_SetMimpiMap(char *filename) { BYTE b; FILEH fh; char buf[128]; LOADED_TONEMAP = 0; ZeroMemory(TONE_CH, sizeof(TONE_CH)); ZeroMemory(TONEBANK[0], sizeof(TONEBANK)); for (b=0; b<128; b++) { TONEMAP[0][b] = b; TONEMAP[1][b] = b; TONEMAP[2][b] = b; } TONE_CH[9] = MIMPI_RHYTHM; if ((filename == NULL) || (!filename[0])) { ENABLE_TONEMAP = 0; return(FALSE); } fh = File_Open(filename); if (fh == (FILEH)-1) { ENABLE_TONEMAP = 0; return(FALSE); } while(file_readline(fh, buf, sizeof(buf)) >= 0) { mimpidefline_analaize(buf); } File_Close(fh); LOADED_TONEMAP = 1; return(TRUE); }
/* write config to file */ void writeconfig(_In_ Config* config) { FILE* configfile = File_Open(config->configFilepath, "w"); if (!configfile) { return; } LOGMSG(("created config file (%s)", config->configFilepath)); fprintf(configfile, gformat1, config->testGroup, config->intervalMS, config->failAfterCount, config->failResult, config->initBehavior, config->initResultCode, config->initTimeoutMS, config->finalizeBehavior, config->finalizeResultCode, config->postBehavior, config->miscTestSubGroup, config->evalResult, config->logLoadUnloadCall); fprintf(configfile, gformat2, config->subscribeBookmark, config->providerBookmark, config->dialect, config->expression); File_Close(configfile); }
void ScreenGrab_Update( void ) { char lFileName[ 264 ]; sDegasHeader lHeader; sFileHandle lHandle; if( IKBD_GetKeyStatus( gScreenGrabKeyIndex ) ) { if( !gScreenGrabKeyState ) { sprintf( lFileName, "%sGRAB%04x.PI1", gScreenGrabDirectory, gScreenGrabIndex ); lHandle = File_Create( lFileName ); if( lHandle > 0 ) { lHeader.Mode = 0; Video_GetPalST( &lHeader.Palette[ 0 ] ); File_Write( lHandle, sizeof(sDegasHeader), &lHeader ); File_Write( lHandle, 32000, Video_GetpPhysic() ); File_Close( lHandle ); gScreenGrabIndex++; } gScreenGrabKeyState = 1; } } else { gScreenGrabKeyState = 0; } }
VOID Mij_SetButton( MOTIONINJOY_BUTTON_MAP* ButtonMapping ) { HANDLE driverHandle; IO_STATUS_BLOCK isb; MOTIONINJOY_APP_OPTION options; File_Create( &driverHandle, L"\\\\.\\MIJFilter", SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL ); Memory_Clear(&options, sizeof(MOTIONINJOY_APP_OPTION)); options.CommonOption.mode = Keyboard; options.CommonOption.LED = 129; options.CommonOption.AutoOff_timeout = 0x80 | /*PushSharedMemory->ControllerTimeout*/10; //minutes options.CommonOption.Deadzone_LStick_X = 10; options.CommonOption.Deadzone_LStick_Y = 10; options.InputOption.Duration = 100; options.InputOption.Interval = 400; Memory_Copy(&options.InputOption.Maping, ButtonMapping, sizeof(MOTIONINJOY_BUTTON_MAP)); NtDeviceIoControlFile(driverHandle, NULL, NULL, NULL, &isb, IOCTL_MIJ_SET_CONFIG_OPTIONS, &options, 256, NULL, 0); File_Close(driverHandle); }
/** * Seek inside a file. * * @param index The index given by File_Open() of the file. * @param position Position to fix to. * @param mode Mode of seeking. 0 = SEEK_SET, 1 = SEEK_CUR, 2 = SEEK_END. * @return The new position inside the file, relative from the start. */ uint32 File_Seek(uint8 index, uint32 position, uint8 mode) { if (index >= FILE_MAX) return 0; if (s_file[index].fp == NULL) return 0; if (mode > 2) { File_Close(index); return 0; } g_fileOperation++; switch (mode) { case 0: fseek(s_file[index].fp, s_file[index].start + position, SEEK_SET); s_file[index].position = position; break; case 1: fseek(s_file[index].fp, (int32)position, SEEK_CUR); s_file[index].position += (int32)position; break; case 2: fseek(s_file[index].fp, s_file[index].start + s_file[index].size - position, SEEK_SET); s_file[index].position = s_file[index].size - position; break; } g_fileOperation--; return s_file[index].position; }
SizeT _MPIStream_Printf( Stream* stream, char *fmt, va_list args ) { MPIStream* self = (MPIStream*)stream; MPI_Status status; char* buffer; SizeT numChars; int writeResult; if ( self->_file == NULL ) { return 0; } numChars = Stg_vasprintf( &buffer, fmt, args ); writeResult = MPI_File_write( *(MPI_File*)(self->_file->fileHandle), buffer, numChars, MPI_BYTE, &status ); if (writeResult != MPI_SUCCESS) { char errorString[2000]; int errorStringLength = 0; Stream* errorStream = Journal_Register( Error_Type, MPIFile_Type ); int myRank = 0; MPI_Comm_rank( MPI_COMM_WORLD, &myRank ); MPI_Error_string( writeResult, errorString, &errorStringLength); Journal_Printf( errorStream, "%3d: %s\n", myRank, errorString ); File_Close( self->_file ); MPI_Abort(MPI_COMM_WORLD, writeResult ); } Memory_Free( buffer ); return 0; }
void Profiler_DeInit( void ) { Profiler_Disable(); *(U32*)0x68 = gProfilerOldHBL; File_Close( gProfilerHandle ); Memory_Release( gpProfilerBuffer ); }
void SetMacro( unsigned __int8 Count, MOTIONINJOY_MACRO* Macro ) { HANDLE driverHandle; BYTE b; MOTIONINJOY_BUTTON_MACRO macro; IO_STATUS_BLOCK isb; File_Create( &driverHandle, L"\\\\.\\MIJFilter", SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL ); Memory_Clear(¯o, sizeof(MOTIONINJOY_BUTTON_MACRO)); macro.DeviceIndex = 0; macro.EIndex = 0; b = 0; while ((int)b < ((Count > 6) ? 6 : Count)) { int i; macro.MacroIndex = b; macro.Duration = Macro->Duration; Memory_Copy(macro.Command, Macro->Command, sizeof(macro.Command)); // Fill button intervals for (i = 0; i < 6; i++) { macro.ButtonIndex = i; Memory_Copy(macro.Button, Macro->ButtonIntervals[i], sizeof(macro.Button)); NtDeviceIoControlFile( driverHandle, NULL, NULL, NULL, &isb, IOCTL_MIJ_SET_CONFIG_MACRO, ¯o, sizeof(MOTIONINJOY_BUTTON_MACRO), NULL, 0 ); } b++; Macro++; } File_Close(driverHandle); }
void Qt7zPackage::close() { if (m_p->m_isOpen) { SzArEx_Free(&(m_p->m_db), &(m_p->m_allocImp)); File_Close(&(m_p->m_archiveStream.file)); m_p->m_isOpen = false; } }
/** * Reads length bytes from filename into buffer. * * @param filename Then name of the file to read. * @param buffer The buffer to read into. * @param length The amount of bytes to read. * @return The amount of bytes truly read, or 0 if there was a failure. */ uint32 File_ReadBlockFile(const char *filename, void *buffer, uint32 length) { uint8 index; index = File_Open(filename, 1); length = File_Read(index, buffer, length); File_Close(index); return length; }
void SZFilePack::close() { if (mIsPackOpened) { SzArEx_Free(&mDb, &mAllocImp); File_Close(&mArchiveStream.file); mIndexMap.clear(); mIsPackOpened = false; } }
static void file_selection_ok(GtkWidget *w, GtkFileSelection *gfs) { file_selection_t *fsp = (file_selection_t *)gfs; GtkFileSelection *fs = (GtkFileSelection *)fsp->fs; char *p; UNUSED(w); p = (char *)gtk_file_selection_get_filename(fs); if (p) { struct stat st; if (stat(p, &st) == 0) { if (!S_ISDIR(st.st_mode)) { switch (fsp->type) { case 1: // open MIMPI tone map gtk_entry_set_text(GTK_ENTRY(fsp->arg), p); strncpy(ConfigProp.ToneMapFile, p, sizeof(ConfigProp.ToneMapFile)); break; case 2: // open SASI HDD { sasi_hdd_t *sasi_hdd = (sasi_hdd_t *)fsp->arg; strncpy(ConfigProp.HDImage[sasi_hdd->idx], p, sizeof(ConfigProp.HDImage[0])); gtk_entry_set_text(GTK_ENTRY(sasi_hdd->entry), p); } break; } } } else if (errno == ENOENT) { switch (fsp->type) { case 3: // create SASI HDD image { sasi_hdd_t *sasi_hdd = (sasi_hdd_t *)fsp->arg; char buf[0x1000]; FILEH *fh; int i; fh = File_Create(p, FTYPE_NONE); if (fh == INVALID_HANDLE_VALUE) break; bzero(buf, sizeof(buf)); for (i = 0; i < 0x2793 /* 40Mb/0x1000 */; ++i) File_Write(fh, buf, 0x1000); File_Close(fh); strncpy(ConfigProp.HDImage[sasi_hdd->idx], p, sizeof(ConfigProp.HDImage[0])); gtk_entry_set_text(GTK_ENTRY(sasi_hdd->entry), p); } break; } } } gtk_widget_destroy(GTK_WIDGET(fs)); }
/** * Uninitialise Printer */ void Printer_UnInit(void) { Dprintf((stderr, "Printer_UnInit()\n")); /* Close any open files */ pPrinterHandle = File_Close(pPrinterHandle); bUnflushed = false; nIdleCount = 0; }
T_BOOL Fwl_FileClose(T_hFILE hFile) { if (FS_INVALID_HANDLE == hFile) { return AK_FALSE; } File_Close(hFile); return AK_TRUE; }
CArchive7Zip::~CArchive7Zip() { if (outBuffer) { IAlloc_Free(&allocImp, outBuffer); } if (isOpen) { File_Close(&archiveStream.file); } SzArEx_Free(&db, &allocImp); }
int File_ExistW( _In_z_ const wchar_t *path) { FILE *fp = File_OpenW(path, L"r"); if( !fp) return -1; File_Close(fp); return 0; }
int File_Exist( _In_z_ const char *path) { FILE *fp = File_Open(path, "r"); if( !fp) return -1; File_Close(fp); return 0; }
//关闭 T_BOOL Fwl_FileClose(T_hFILE hFile) { //判断句柄是否有效 if (hFile != FS_INVALID_HANDLE) { File_Close((T_hFILE)hFile); } return AK_TRUE; }
SRes SzArEx_Extract( const CSzArEx *p, ISeekInStream *inStream, const UInt16 *outputDir, ICompressProgress *progress, ISzAlloc *allocTemp) { UInt32 blockIndex = 0xffffffff; UInt64 totalUnpackSize = 0; UInt32 i; SRes res = SZ_OK; for (i = 0; i < p->db.NumFolders; i++) { CSzFolder *folder = p->db.Folders + i; UInt64 unpackSize = SzFolder_GetUnpackSize(folder); totalUnpackSize += unpackSize; } if(progress != NULL) CompressCallback_Init((CCompressCallback*)progress,totalUnpackSize); for (i = 0; i < p->db.NumFiles; i++) { UInt32 folderIndex = p->FileIndexToFolderIndexMap[i]; if (folderIndex == (UInt32)-1) { blockIndex = folderIndex; continue; } if(folderIndex != blockIndex) { CSzFolder *folder = p->db.Folders + folderIndex; UInt64 unpackSizeSpec = SzFolder_GetUnpackSize(folder); size_t unpackSize = (size_t)unpackSizeSpec; UInt64 startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); CFolderOutStream outStream; FolderOutStream_Init(&outStream,p,folderIndex,outputDir); if (unpackSize != unpackSizeSpec) return SZ_ERROR_MEM; blockIndex = folderIndex; res = SzFolder_Decode(folder, p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex], inStream, startOffset, &outStream.s, unpackSize, progress, allocTemp); File_Close(&outStream.file); if(res != SZ_OK) break; } } return res; }
T_BOOL Fwl_FsIsDir(T_pCWSTR path) { T_BOOL Ret = AK_FALSE; T_hFILE file = FS_INVALID_HANDLE; file = File_OpenUnicode((T_hFILE)AK_NULL, path, FILE_MODE_READ); Ret = File_IsFolder(file); File_Close(file); return Ret; }
/** * Close all open output file, empty buffers etc. */ void Printer_CloseAllConnections(void) { /* Empty buffer */ Printer_EmptyInternalBuffer(); /* Close any open files */ pPrinterHandle = File_Close(pPrinterHandle); /* Signal finished with printing */ bConnectedPrinter = FALSE; }
_Use_decl_annotations_ MI_Result Config_Finalize(Config* config) { if ( config->apilogfile ) { File_Close( config->apilogfile ); config->apilogfile = NULL; } LifecycleEventQueue_Finalize( &config->lifecycleQueue ); return MI_RESULT_OK; }
bool _vd7zClose(struct VDir* vd) { struct VDir7z* vd7z = (struct VDir7z*) vd; SzArEx_Free(&vd7z->db, &vd7z->allocImp); File_Close(&vd7z->archiveStream.file); free(vd7z->dirent.utf8); vd7z->dirent.utf8 = 0; free(vd7z); return true; }
SzArchive::~SzArchive() { if (lookStream.buf != NULL) { File_Close(&archiveStream.file); ISzAlloc_Free(&g_Alloc, lookStream.buf); if (out_buffer != NULL) ISzAlloc_Free(&g_Alloc, out_buffer); SzArEx_Free(&szarchive, &g_Alloc); } }
T_BOOL Fwl_FileStat(T_pCWSTR path, T_hFILEINFO hFileInfo) { T_hFILE file = 0; T_PFILEINFO pFileInfo = (T_PFILEINFO)hFileInfo; if (AK_NULL == pFileInfo) { return AK_FALSE; } file = File_OpenUnicode((T_hFILE)AK_NULL, path, FILE_MODE_READ); if (!File_Exist(file)) { File_Close(file); return AK_FALSE; } File_GetFileinfo(file, pFileInfo); File_Close(file); return AK_TRUE; }
int File_Touch( _In_z_ const char* path) { FILE* fp = File_Open(path, "w"); if (!fp) return -1; File_Close(fp); return 0; }