这篇教程C++ ASIZE函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ASIZE函数的典型用法代码示例。如果您正苦于以下问题:C++ ASIZE函数的具体用法?C++ ASIZE怎么用?C++ ASIZE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ASIZE函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: wcsncpyzbool FindFile::Next(FindData *fd,bool GetSymLink){ fd->Error=false; if (*FindMask==0) return false;#ifdef _WIN_ALL if (FirstCall) { if ((hFind=Win32Find(INVALID_HANDLE_VALUE,FindMask,fd))==INVALID_HANDLE_VALUE) return false; } else if (Win32Find(hFind,FindMask,fd)==INVALID_HANDLE_VALUE) return false;#else if (FirstCall) { wchar DirName[NM]; wcsncpyz(DirName,FindMask,ASIZE(DirName)); RemoveNameFromPath(DirName); if (*DirName==0) wcscpy(DirName,L"."); char DirNameA[NM]; WideToChar(DirName,DirNameA,ASIZE(DirNameA)); if ((dirp=opendir(DirNameA))==NULL) { fd->Error=(errno!=ENOENT); return false; } } while (1) { struct dirent *ent=readdir(dirp); if (ent==NULL) return false; if (strcmp(ent->d_name,".")==0 || strcmp(ent->d_name,"..")==0) continue; wchar Name[NM]; if (!CharToWide(ent->d_name,Name,ASIZE(Name))) Log(NULL,St(MInvalidName),Name); if (CmpName(FindMask,Name,MATCH_NAMES)) { wchar FullName[NM]; wcscpy(FullName,FindMask); *PointToName(FullName)=0; if (wcslen(FullName)+wcslen(Name)>=ASIZE(FullName)-1) {#ifndef SILENT Log(NULL,L"/n%ls%ls",FullName,Name); Log(NULL,St(MPathTooLong));#endif return false; } wcscat(FullName,Name); if (!FastFind(FullName,fd,GetSymLink)) { ErrHandler.OpenErrorMsg(NULL,FullName); continue; } wcscpy(fd->Name,FullName); break; } }#endif fd->Flags=0; fd->IsDir=IsDir(fd->FileAttr); fd->IsLink=IsLink(fd->FileAttr); FirstCall=false; wchar *NameOnly=PointToName(fd->Name); if (wcscmp(NameOnly,L".")==0 || wcscmp(NameOnly,L"..")==0) return Next(fd); return true;}
开发者ID:717717,项目名称:sumatrapdf,代码行数:75,
示例2: mainint main(int argc, char **argv){ int cnt, x, y, i = 0, verbose = 0; Window win = 0; Bool keysymMappingInitialized = False; int rc = 0; int inputEvents[100]; int inputEventsIndex = 0; int iEvent = 0; if (argc == 1) usage(argv[0]); const char* log_file = NULL; if (streq(argv[1],"-o") || streq(argv[1],"--logfile")) { i++; if (++i > argc) usage(argv[0]); log_file = argv[i]; } report_init(log_file); if (!xhandler_init(getenv("DISPLAY"))) exit(1); report_add_message(xhandler_get_server_time(), "Startup/n"); /* initialize subsystems */ xemu_init(xhandler.display); scheduler_init(xhandler.display); window_init(xhandler.display); application_init(); /* * Process the command line options. * Skip emulation options (--click, --drag, --key, --type), but remember they index * and process them later. */ while (++i < argc) { if (streq(argv[i],"-v") || streq(argv[i],"--verbose")) { verbose = 1; continue; } if (streq(argv[i], "-id") || streq(argv[i], "--id")) { char name[PATH_MAX]; if (++i >= argc) usage(argv[0]); cnt = sscanf(argv[i], "0x%lx", &win); if (cnt < 1) { cnt = sscanf(argv[i], "%lu", &win); } if (cnt < 1) { fprintf(stderr, "*** invalid window id '%s'/n", argv[i]); usage(argv[0]); } sprintf(name, "0x%lx", win); if (!window_add(win, application_monitor(name))) { fprintf(stderr, "Could not setup damage monitoring for window 0x%lx!/n", win); exit(1); } if (verbose) report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring window 0x%lx/n", win); continue; } if (streq(argv[i], "-a") || streq(argv[i], "--application")) { if (++i >= argc) usage(argv[0]); response.application = application_monitor(argv[i]); if (response.application && verbose) { report_add_message(REPORT_LAST_TIMESTAMP, "Monitoring application '%s'/n", argv[i]); } if (!strcmp(argv[i], "*")) { application_set_monitor_all(true); } continue; } if (streq("-c", argv[i]) || streq("--click", argv[i])) { if (!xemu.pointer.dev) { fprintf(stderr, "Failed to open pointer device, unable to simulate pointer events./n"); exit(-1); } if (inputEventsIndex == ASIZE(inputEvents)) { fprintf(stderr, "Too many input events specified/n"); exit(-1); } if (!argv[i + 1] || !match_regex(argv[i + 1], "^[0-9]+x[0-9]+(,[0-9]+)?$")) { fprintf(stderr, "Failed to parse --c options: %s/n", argv[i + 1]); exit(-1); } inputEvents[inputEventsIndex++] = i; if (++i >= argc)//.........这里部分代码省略.........
开发者ID:mer-tools,项目名称:xresponse,代码行数:101,
示例3: mainint main(int argc, char* argv[]){#ifdef _UNIX setlocale(LC_ALL, "");#endif#if defined(_EMX) && !defined(_DJGPP) uni_init(0);#endif#if !defined(_SFX_RTL_) && !defined(_WIN_ALL) setbuf(stdout, NULL);#endif#if !defined(SFX_MODULE) && defined(_EMX) EnumConfigPaths(argv[0], -1);#endif ErrHandler.SetSignalHandlers(true); RARInitData();#ifdef SFX_MODULE char ModuleNameA[NM]; wchar ModuleNameW[NM];#ifdef _WIN_ALL GetModuleFileNameW(NULL, ModuleNameW, ASIZE(ModuleNameW)); WideToChar(ModuleNameW, ModuleNameA);#else strcpy(ModuleNameA, argv[0]); *ModuleNameW = 0;#endif#endif#ifdef _WIN_ALL SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);#endif#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT) bool ShutdownOnClose;#endif#ifdef ALLOW_EXCEPTIONS try#endif { CommandData Cmd;#ifdef SFX_MODULE strcpy(Cmd.Command, "X"); char* Switch = NULL;#ifdef _SFX_RTL_ char* CmdLine = GetCommandLineA(); if (CmdLine != NULL && *CmdLine == '/"') CmdLine = strchr(CmdLine + 1, '/"'); if (CmdLine != NULL && (CmdLine = strpbrk(CmdLine, " /")) != NULL) { while (IsSpace(*CmdLine)) CmdLine++; Switch = CmdLine; }#else Switch = argc > 1 ? argv[1] : NULL;#endif if (Switch != NULL && Cmd.IsSwitch(Switch[0])) { int UpperCmd = etoupper(Switch[1]); switch (UpperCmd) { case 'T': case 'V': Cmd.Command[0] = UpperCmd; break; case '?': Cmd.OutHelp(); break; } } Cmd.AddArcName(ModuleNameA, ModuleNameW);#else if (Cmd.IsConfigEnabled(argc, argv)) { Cmd.ReadConfig(argc, argv); Cmd.ParseEnvVar(); } for (int I = 1; I < argc; I++) Cmd.ParseArg(argv[I], NULL);#endif Cmd.ParseDone();#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT) ShutdownOnClose = Cmd.Shutdown;#endif InitConsoleOptions(Cmd.MsgStream, Cmd.Sound); InitLogOptions(Cmd.LogName); ErrHandler.SetSilent(Cmd.AllYes || Cmd.MsgStream == MSG_NULL); ErrHandler.SetShutdown(Cmd.Shutdown); Cmd.OutTitle(); Cmd.ProcessCommand();//.........这里部分代码省略.........
开发者ID:Tyf0n,项目名称:Rar_crack,代码行数:101,
示例4: GetWinLongPath// We should return 'true' even if resulting path is shorter than MAX_PATH,// because we can also use this function to open files with non-standard// characters, even if their path length is normal.bool GetWinLongPath(const wchar *Src,wchar *Dest,size_t MaxSize){ if (*Src==0) return false; const wchar *Prefix=L"////?//"; const size_t PrefixLength=4; bool FullPath=IsDiskLetter(Src) && IsPathDiv(Src[2]); size_t SrcLength=wcslen(Src); if (IsFullPath(Src)) // Paths in d:/path/name format. { if (IsDiskLetter(Src)) { if (MaxSize<=PrefixLength+SrcLength) return false; wcsncpy(Dest,Prefix,PrefixLength); wcscpy(Dest+PrefixLength,Src); return true; } else if (Src[0]=='//' && Src[1]=='//') { if (MaxSize<=PrefixLength+SrcLength+2) return false; wcsncpy(Dest,Prefix,PrefixLength); wcscpy(Dest+PrefixLength,L"UNC"); wcscpy(Dest+PrefixLength+3,Src+1); return true; } // We may be here only if we modify IsFullPath in the future. return false; } else { wchar CurDir[NM]; DWORD DirCode=GetCurrentDirectory(ASIZE(CurDir)-1,CurDir); if (DirCode==0 || DirCode>ASIZE(CurDir)-1) return false; if (IsPathDiv(Src[0])) // Paths in /path/name format. { if (MaxSize<=PrefixLength+SrcLength+2) return false; wcsncpy(Dest,Prefix,PrefixLength); wcsncpy(Dest+PrefixLength,CurDir,2); // Copy drive letter 'd:'. wcscpy(Dest+PrefixLength+2,Src); return true; } else // Paths in path/name format. { AddEndSlash(CurDir,ASIZE(CurDir)); if (MaxSize<=PrefixLength+wcslen(CurDir)+SrcLength) return false; wcsncpy(Dest,Prefix,PrefixLength); wcscpy(Dest+PrefixLength,CurDir); if (Src[0]=='.' && IsPathDiv(Src[1])) // Remove leading ./ in pathname. Src+=2; wcsncatz(Dest,Src,MaxSize); return true; } } return false;}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:67,
示例5: Raw//.........这里部分代码省略......... // RAR 4.x Unix symlink. if (hd->HostOS==HOST_UNIX && (hd->FileAttr & 0xF000)==0xA000) { hd->RedirType=FSREDIR_UNIXSYMLINK; *hd->RedirName=0; } hd->Inherited=!FileBlock && (hd->SubFlags & SUBHEAD_FLAGS_INHERITED)!=0; hd->LargeFile=(hd->Flags & LHD_LARGE)!=0; uint HighPackSize,HighUnpSize; if (hd->LargeFile) { HighPackSize=Raw.Get4(); HighUnpSize=Raw.Get4(); hd->UnknownUnpSize=(LowUnpSize==0xffffffff && HighUnpSize==0xffffffff); } else { HighPackSize=HighUnpSize=0; // UnpSize equal to 0xffffffff without LHD_LARGE flag indicates // that we do not know the unpacked file size and must unpack it // until we find the end of file marker in compressed data. hd->UnknownUnpSize=(LowUnpSize==0xffffffff); } hd->PackSize=INT32TO64(HighPackSize,hd->DataSize); hd->UnpSize=INT32TO64(HighUnpSize,LowUnpSize); if (hd->UnknownUnpSize) hd->UnpSize=INT64NDF; char FileName[NM*4]; size_t ReadNameSize=Min(NameSize,ASIZE(FileName)-1); Raw.GetB((byte *)FileName,ReadNameSize); FileName[ReadNameSize]=0; if (FileBlock) { if ((hd->Flags & LHD_UNICODE)!=0) { EncodeFileName NameCoder; size_t Length=strlen(FileName); if (Length==NameSize) UtfToWide(FileName,hd->FileName,ASIZE(hd->FileName)-1); else { Length++; NameCoder.Decode(FileName,(byte *)FileName+Length, NameSize-Length,hd->FileName, ASIZE(hd->FileName)); } } else *hd->FileName=0; char AnsiName[NM]; IntToExt(FileName,AnsiName,ASIZE(AnsiName)); GetWideName(AnsiName,hd->FileName,hd->FileName,ASIZE(hd->FileName));#ifndef SFX_MODULE ConvertNameCase(hd->FileName);#endif ConvertFileHeader(hd); } else
开发者ID:Armada651,项目名称:comicsreader,代码行数:67,
示例6: ExtractStreams20void ExtractStreams20(Archive &Arc,const wchar *FileName){ if (Arc.BrokenHeader) { uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName); ErrHandler.SetErrorCode(RARX_CRC); return; } if (Arc.StreamHead.Method<0x31 || Arc.StreamHead.Method>0x35 || Arc.StreamHead.UnpVer>VER_PACK) { uiMsg(UIERROR_STREAMUNKNOWN,Arc.FileName,FileName); ErrHandler.SetErrorCode(RARX_WARNING); return; } wchar StreamName[NM+2]; if (FileName[0]!=0 && FileName[1]==0) { wcscpy(StreamName,L".//"); wcscpy(StreamName+2,FileName); } else wcscpy(StreamName,FileName); if (wcslen(StreamName)+strlen(Arc.StreamHead.StreamName)>=ASIZE(StreamName) || Arc.StreamHead.StreamName[0]!=':') { uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName); ErrHandler.SetErrorCode(RARX_CRC); return; } wchar StoredName[NM]; CharToWide(Arc.StreamHead.StreamName,StoredName,ASIZE(StoredName)); ConvertPath(StoredName+1,StoredName+1); wcsncatz(StreamName,StoredName,ASIZE(StreamName)); FindData fd; bool Found=FindFile::FastFind(FileName,&fd); if ((fd.FileAttr & FILE_ATTRIBUTE_READONLY)!=0) SetFileAttr(FileName,fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); File CurFile; if (CurFile.WCreate(StreamName)) { ComprDataIO DataIO; Unpack Unpack(&DataIO); Unpack.Init(0x10000,false); DataIO.SetPackedSizeToRead(Arc.StreamHead.DataSize); DataIO.EnableShowProgress(false); DataIO.SetFiles(&Arc,&CurFile); DataIO.UnpHash.Init(HASH_CRC32,1); Unpack.SetDestSize(Arc.StreamHead.UnpSize); Unpack.DoUnpack(Arc.StreamHead.UnpVer,false); if (Arc.StreamHead.StreamCRC!=DataIO.UnpHash.GetCRC32()) { uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,StreamName); ErrHandler.SetErrorCode(RARX_CRC); } else CurFile.Close(); } File HostFile; if (Found && HostFile.Open(FileName,FMF_OPENSHARED|FMF_UPDATE)) SetFileTime(HostFile.GetHandle(),&fd.ftCreationTime,&fd.ftLastAccessTime, &fd.ftLastWriteTime); if ((fd.FileAttr & FILE_ATTRIBUTE_READONLY)!=0) SetFileAttr(FileName,fd.FileAttr);}
开发者ID:Cpasjuste,项目名称:nzbm,代码行数:73,
示例7: returnbool ScanTree::GetNextMask(){ if (!FileMasks->GetString(CurMask,CurMaskW,ASIZE(CurMask))) return(false); if (*CurMask==0 && *CurMaskW!=0) { // Unicode only mask is present. It is very unlikely in console tools, // but possible if called from GUI WinRAR. We still need to have // ASCII mask, because we use ASCII only mask in some checks later. // So let's convert Unicode to ASCII. WideToChar(CurMaskW,CurMask,ASIZE(CurMask)); } CurMask[ASIZE(CurMask)-1]=0; CurMaskW[ASIZE(CurMaskW)-1]=0;#ifdef _WIN_ALL UnixSlashToDos(CurMask);#endif // We wish to scan entire disk if mask like c:/ is specified // regardless of recursion mode. Use c:/*.* mask when need to scan only // the root directory. ScanEntireDisk=IsDiskLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0; char *Name=PointToName(CurMask); if (*Name==0) strcat(CurMask,MASKALL); if (Name[0]=='.' && (Name[1]==0 || Name[1]=='.' && Name[2]==0)) { AddEndSlash(CurMask); strcat(CurMask,MASKALL); } SpecPathLength=Name-CurMask; bool WideName=(*CurMaskW!=0); if (WideName) { wchar *NameW=PointToName(CurMaskW); if (*NameW==0) wcscat(CurMaskW,MASKALLW); if (NameW[0]=='.' && (NameW[1]==0 || NameW[1]=='.' && NameW[2]==0)) { AddEndSlash(CurMaskW); wcscat(CurMaskW,MASKALLW); } SpecPathLengthW=NameW-CurMaskW; } else { wchar WideMask[NM]; CharToWide(CurMask,WideMask); SpecPathLengthW=PointToName(WideMask)-WideMask; } Depth=0; strcpy(OrigCurMask,CurMask); wcscpy(OrigCurMaskW,CurMaskW); return(true);}
开发者ID:DreamingPiggy,项目名称:xreader-hg,代码行数:62,
示例8: mprintfvoid CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName){ return; // OPENMPT ADDITION if (Cmd->Test) {#ifndef GUI mprintf(St(MExtrTestFile),ArcFileName); mprintf(L" %s",St(MOk));#endif return; } MKDIR_CODE MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); bool DirExist=false; if (MDCode!=MKDIR_SUCCESS) { DirExist=FileExist(DestFileName); if (DirExist && !IsDir(GetFileAttr(DestFileName))) { // File with name same as this directory exists. Propose user // to overwrite it. bool UserReject; FileCreate(Cmd,NULL,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime); DirExist=false; } if (!DirExist) { CreatePath(DestFileName,true); MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr); } } if (MDCode==MKDIR_SUCCESS) {#ifndef GUI mprintf(St(MCreatDir),DestFileName); mprintf(L" %s",St(MOk));#endif PrevExtracted=true; } else if (DirExist) { if (!Cmd->IgnoreGeneralAttr) SetFileAttr(DestFileName,Arc.FileHead.FileAttr); PrevExtracted=true; } else { uiMsg(UIERROR_DIRCREATE,Arc.FileName,DestFileName); ErrHandler.SysErrMsg();#ifdef RARDLL Cmd->DllError=ERAR_ECREATE;#endif ErrHandler.SetErrorCode(RARX_CREATE); } if (PrevExtracted) {#if defined(_WIN_ALL) && !defined(SFX_MODULE) if (Cmd->SetCompressedAttr && (Arc.FileHead.FileAttr & FILE_ATTRIBUTE_COMPRESSED)!=0 && WinNT()) SetFileCompression(DestFileName,true);#endif SetDirTime(DestFileName, Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.FileHead.mtime, Cmd->xctime==EXTTIME_NONE ? NULL:&Arc.FileHead.ctime, Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.FileHead.atime); }}
开发者ID:ksnydertn,项目名称:modplug,代码行数:68,
示例9: print_insn_pj//.........这里部分代码省略......... int lowval; int highval; int val; addr = (addr + 3) & ~3; if ((status = get_int (addr, &val, info))) goto fail; fprintf_fn (stream, " default: "); (*info->print_address_func) (val + insn_start, info); addr += 4; if ((status = get_int (addr, &lowval, info))) goto fail; addr += 4; if ((status = get_int (addr, &highval, info))) goto fail; addr += 4; while (lowval <= highval) { if ((status = get_int (addr, &val, info))) goto fail; fprintf_fn (stream, " %d:[", lowval); (*info->print_address_func) (val + insn_start, info); fprintf_fn (stream, " ]"); addr += 4; lowval++; } return addr - insn_start; } /* The lookupswitch instruction is followed by the default address, element count and pairs of values and addresses. */ if (strcmp (op->u.name, "lookupswitch") == 0) { int count; int val; addr = (addr + 3) & ~3; if ((status = get_int (addr, &val, info))) goto fail; addr += 4; fprintf_fn (stream, " default: "); (*info->print_address_func) (val + insn_start, info); if ((status = get_int (addr, &count, info))) goto fail; addr += 4; while (count--) { if ((status = get_int (addr, &val, info))) goto fail; addr += 4; fprintf_fn (stream, " %d:[", val); if ((status = get_int (addr, &val, info))) goto fail; addr += 4; (*info->print_address_func) (val + insn_start, info); fprintf_fn (stream, " ]"); } return addr - insn_start; } for (a = 0; op->arg[a]; a++) { unsigned char data[4]; int val = 0; int i; int size = ASIZE (op->arg[a]); if ((status = info->read_memory_func (addr, data, size, info))) goto fail; val = (UNS (op->arg[0]) || ((data[0] & 0x80) == 0)) ? 0 : -1; for (i = 0; i < size; i++) val = (val << 8) | (data[i] & 0xff); if (PCREL (op->arg[a])) (*info->print_address_func) (val + insn_start, info); else fprintf_fn (stream, "%s%d", sep, val); sep = ","; addr += size; } return op->len; } fail: info->memory_error_func (status, addr, info); return -1;}
开发者ID:3125788,项目名称:android_toolchain_gdb,代码行数:101,
示例10: ArcEXTRACT_ARC_CODE CmdExtract::ExtractArchive(){ Archive Arc(Cmd); if (!Arc.WOpen(ArcName)) return EXTRACT_ARC_NEXT; if (!Arc.IsArchive(true)) {#ifndef GUI mprintf(St(MNotRAR),ArcName);#endif if (CmpExt(ArcName,L"rar")) ErrHandler.SetErrorCode(RARX_WARNING); return EXTRACT_ARC_NEXT; } if (Arc.FailedHeaderDecryption) // Bad archive password. return EXTRACT_ARC_NEXT;#ifndef SFX_MODULE if (Arc.Volume && !Arc.FirstVolume) { wchar FirstVolName[NM]; VolNameToFirstName(ArcName,FirstVolName,ASIZE(FirstVolName),Arc.NewNumbering); // If several volume names from same volume set are specified // and current volume is not first in set and first volume is present // and specified too, let's skip the current volume. if (wcsicomp(ArcName,FirstVolName)!=0 && FileExist(FirstVolName) && Cmd->ArcNames.Search(FirstVolName,false)) return EXTRACT_ARC_NEXT; }#endif int64 VolumeSetSize=0; // Total size of volumes after the current volume. if (Arc.Volume) { // Calculate the total size of all accessible volumes. // This size is necessary to display the correct total progress indicator. wchar NextName[NM]; wcscpy(NextName,Arc.FileName); while (true) { // First volume is already added to DataIO.TotalArcSize // in initial TotalArcSize calculation in DoExtract. // So we skip it and start from second volume. NextVolumeName(NextName,ASIZE(NextName),!Arc.NewNumbering); FindData FD; if (FindFile::FastFind(NextName,&FD)) VolumeSetSize+=FD.Size; else break; } DataIO.TotalArcSize+=VolumeSetSize; } ExtractArchiveInit(Arc); if (*Cmd->Command=='T' || *Cmd->Command=='I') Cmd->Test=true; if (*Cmd->Command=='I') {#ifndef GUI Cmd->DisablePercentage=true;#endif } else uiStartArchiveExtract(!Cmd->Test,ArcName); Arc.ViewComment(); while (1) { size_t Size=Arc.ReadHeader(); bool Repeat=false; if (!ExtractCurrentFile(Arc,Size,Repeat)) if (Repeat) { // If we started extraction from not first volume and need to // restart it from first, we must correct DataIO.TotalArcSize // for correct total progress display. We subtract the size // of current volume and all volumes after it and add the size // of new (first) volume. FindData OldArc,NewArc; if (FindFile::FastFind(Arc.FileName,&OldArc) && FindFile::FastFind(ArcName,&NewArc)) DataIO.TotalArcSize-=VolumeSetSize+OldArc.Size-NewArc.Size; return EXTRACT_ARC_REPEAT; } else break; }//.........这里部分代码省略.........
开发者ID:ksnydertn,项目名称:modplug,代码行数:101,
示例11: SetExtraInfo20bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat){ wchar Command=Cmd->Command[0]; if (HeaderSize==0) if (DataIO.UnpVolume) {#ifdef NOVOLUME return false;#else if (!MergeArchive(Arc,&DataIO,false,Command)) { ErrHandler.SetErrorCode(RARX_WARNING); return false; }#endif } else return false; HEADER_TYPE HeaderType=Arc.GetHeaderType(); if (HeaderType!=HEAD_FILE) {#ifndef SFX_MODULE if (HeaderType==HEAD3_OLDSERVICE && PrevExtracted) SetExtraInfo20(Cmd,Arc,DestFileName);#endif if (HeaderType==HEAD_SERVICE && PrevExtracted) SetExtraInfo(Cmd,Arc,DestFileName); if (HeaderType==HEAD_ENDARC) if (Arc.EndArcHead.NextVolume) {#ifndef NOVOLUME if (!MergeArchive(Arc,&DataIO,false,Command)) { ErrHandler.SetErrorCode(RARX_WARNING); return false; }#endif Arc.Seek(Arc.CurBlockPos,SEEK_SET); return true; } else return false; Arc.SeekToNext(); return true; } PrevExtracted=false; if (!Cmd->Recurse && MatchedArgs>=Cmd->FileArgs.ItemsCount() && AllMatchesExact) return false; int MatchType=MATCH_WILDSUBPATH; bool EqualNames=false; int MatchNumber=Cmd->IsProcessFile(Arc.FileHead,&EqualNames,MatchType); bool ExactMatch=MatchNumber!=0;#ifndef SFX_MODULE if (Cmd->ExclPath==EXCL_BASEPATH) { *Cmd->ArcPath=0; if (ExactMatch) { Cmd->FileArgs.Rewind(); if (Cmd->FileArgs.GetString(Cmd->ArcPath,ASIZE(Cmd->ArcPath),MatchNumber-1)) *PointToName(Cmd->ArcPath)=0; } }#endif if (ExactMatch && !EqualNames) AllMatchesExact=false; Arc.ConvertAttributes();#if !defined(SFX_MODULE) && !defined(RARDLL) if (Arc.FileHead.SplitBefore && FirstFile) { wchar CurVolName[NM]; wcsncpyz(CurVolName,ArcName,ASIZE(CurVolName)); VolNameToFirstName(ArcName,ArcName,ASIZE(ArcName),Arc.NewNumbering); if (wcsicomp(ArcName,CurVolName)!=0 && FileExist(ArcName)) { // If first volume name does not match the current name and if such // volume name really exists, let's unpack from this first volume. Repeat=true; return false; }#ifndef RARDLL if (!ReconstructDone) { ReconstructDone=true; if (RecVolumesRestore(Cmd,Arc.FileName,true)) { Repeat=true; return false; } }#endif wcsncpyz(ArcName,CurVolName,ASIZE(ArcName)); }#endif//.........这里部分代码省略.........
开发者ID:ksnydertn,项目名称:modplug,代码行数:101,
示例12: returnbool FindFile::Next(struct FindData *fd,bool GetSymLink){ fd->Error=false; if (*FindMask==0) return(false);#ifdef _WIN_32 if (FirstCall) { if ((hFind=Win32Find(INVALID_HANDLE_VALUE,FindMask,FindMaskW,fd))==INVALID_HANDLE_VALUE) return(false); } else if (Win32Find(hFind,FindMask,FindMaskW,fd)==INVALID_HANDLE_VALUE) return(false);#else if (FirstCall) { char DirName[NM]; strcpy(DirName,FindMask); RemoveNameFromPath(DirName); if (*DirName==0) strcpy(DirName,".");/* else { int Length=strlen(DirName); if (Length>1 && DirName[Length-1]==CPATHDIVIDER && (Length!=3 || !IsDriveDiv(DirName[1]))) DirName[Length-1]=0; }*/ if ((dirp=opendir(DirName))==NULL) { fd->Error=(errno!=ENOENT); return(false); } } while (1) { struct dirent *ent=readdir(dirp); if (ent==NULL) return(false); if (strcmp(ent->d_name,".")==0 || strcmp(ent->d_name,"..")==0) continue; if (CmpName(FindMask,ent->d_name,MATCH_NAMES)) { char FullName[NM]; strcpy(FullName,FindMask); *PointToName(FullName)=0; if (strlen(FullName)+strlen(ent->d_name)>=ASIZE(FullName)-1) {#ifndef SILENT Log(NULL,"/n%s%s",FullName,ent->d_name); Log(NULL,St(MPathTooLong));#endif return(false); } strcat(FullName,ent->d_name); if (!FastFind(FullName,NULL,fd,GetSymLink)) { ErrHandler.OpenErrorMsg(FullName); continue; } strcpy(fd->Name,FullName); break; } } *fd->NameW=0;#ifdef _APPLE if (!LowAscii(fd->Name)) UtfToWide(fd->Name,fd->NameW,sizeof(fd->NameW));#elif defined(UNICODE_SUPPORTED) if (!LowAscii(fd->Name) && UnicodeEnabled()) CharToWide(fd->Name,fd->NameW);#endif#endif fd->IsDir=IsDir(fd->FileAttr); FirstCall=FALSE; char *Name=PointToName(fd->Name); if (strcmp(Name,".")==0 || strcmp(Name,"..")==0) return(Next(fd)); return(true);}
开发者ID:BrunoReX,项目名称:pspcomic,代码行数:82,
示例13: InitLogOptionsvoid InitLogOptions(const wchar *LogFileName,RAR_CHARSET CSet){ wcsncpyz(LogName,LogFileName,ASIZE(LogName)); LogCharset=CSet;}
开发者ID:Armada651,项目名称:comicsreader,代码行数:5,
示例14: init_gpioint init_gpio(void){ char *btn_list[] = { "btn_rst_gpio", "btn_wps_gpio", "fan_gpio", "have_fan_gpio"#ifdef RTCONFIG_WIRELESS_SWITCH , "btn_wifi_gpio"#endif#ifdef RTCONFIG_WIFI_TOG_BTN , "btn_wltog_gpio"#endif#ifdef RTCONFIG_SWMODE_SWITCH#if defined(PLAC66U) , "btn_swmode1_gpio"#else , "btn_swmode1_gpio", "btn_swmode2_gpio", "btn_swmode3_gpio"#endif /* Mode */#endif /* RTCONFIG_SWMODE_SWITCH */#ifdef RTCONFIG_TURBO , "btn_turbo_gpio"#endif#ifdef RTCONFIG_LED_BTN , "btn_led_gpio"#endif#ifdef RTCONFIG_INTERNAL_GOBI , "btn_lte_gpio"#endif }; char *led_list[] = { "led_turbo_gpio", "led_pwr_gpio", "led_usb_gpio", "led_wps_gpio", "fan_gpio", "have_fan_gpio", "led_lan_gpio", "led_wan_gpio", "led_usb3_gpio", "led_2g_gpio", "led_5g_gpio" #ifdef RTCONFIG_LAN4WAN_LED , "led_lan1_gpio", "led_lan2_gpio", "led_lan3_gpio", "led_lan4_gpio"#endif /* LAN4WAN_LED */#ifdef RTCONFIG_LED_ALL , "led_all_gpio"#endif , "led_wan_red_gpio"#ifdef RTCONFIG_QTN , "reset_qtn_gpio"#endif#ifdef RTCONFIG_USBRESET , "pwr_usb_gpio" , "pwr_usb_gpio2"#endif#ifdef RTCONFIG_WIFIPWR , "pwr_2g_gpio" , "pwr_5g_gpio"#endif#ifdef RTCONFIG_INTERNAL_GOBI , "led_3g_gpio", "led_lte_gpio", "led_sig1_gpio", "led_sig2_gpio", "led_sig3_gpio", "led_sig4_gpio"#endif#if (defined(PLN12) || defined(PLAC56)) , "plc_wake_gpio" , "led_pwr_red_gpio" , "led_2g_green_gpio", "led_2g_orange_gpio", "led_2g_red_gpio" , "led_5g_green_gpio", "led_5g_orange_gpio", "led_5g_red_gpio"#endif#ifdef RTCONFIG_MMC_LED , "led_mmc_gpio"#endif#if defined(RTCONFIG_RTAC5300) || defined(RTCONFIG_RTAC5300R) , "rpm_fan_gpio"#endif#ifdef RTCONFIG_RESET_SWITCH , "reset_switch_gpio"#endif }; int use_gpio, gpio_pin; int enable, disable; int i;#ifdef RTCONFIG_INTERNAL_GOBI void get_gpio_values_once(int); get_gpio_values_once(0); // for filling data to led_gpio_table[]#endif /* RTCONFIG_INTERNAL_GOBI */ /* btn input */ for(i = 0; i < ASIZE(btn_list); i++) { if (!nvram_get(btn_list[i])) continue; use_gpio = nvram_get_int(btn_list[i]); if((gpio_pin = use_gpio & 0xff) == 0xff) continue; gpio_dir(gpio_pin, GPIO_DIR_IN); } /* led output */ for(i = 0; i < ASIZE(led_list); i++) { if (!nvram_get(led_list[i])) continue;#if defined(RTCONFIG_ETRON_XHCI_USB3_LED) if (!strcmp(led_list[i], "led_usb3_gpio") && nvram_match("led_usb3_gpio", "etron")) { led_control(LED_USB3, LED_OFF); continue; }#endif use_gpio = nvram_get_int(led_list[i]); if((gpio_pin = use_gpio & 0xff) == 0xff) continue;//.........这里部分代码省略.........
开发者ID:themiron,项目名称:asuswrt-merlin,代码行数:101,
示例15: UpdateExistingShortName// If we find a file, which short name is equal to 'Name', we try to change// its short name, while preserving the long name. It helps when unpacking// an archived file, which long name is equal to short name of already// existing file. Otherwise we would overwrite the already existing file,// even though its long name does not match the name of unpacking file.bool UpdateExistingShortName(wchar *Name){ // 'Name' is the name of file which we want to create. Let's check // if file with such name is exist. If it does not, we return. FindData fd; if (!FindFile::FastFind(NULL,Name,&fd)) return(false); // We continue only if file has a short name, which does not match its // long name, and this short name is equal to name of file which we need // to create. if (*fd.ShortName==0 || wcsicomp(PointToName(fd.NameW),fd.ShortName)==0 || wcsicomp(PointToName(Name),fd.ShortName)!=0) return(false); // Generate the temporary new name for existing file. wchar NewName[NM]; *NewName=0; for (int I=0;I<10000 && *NewName==0;I+=123) { // Here we copy the path part of file to create. We'll make the temporary // file in the same folder. wcsncpyz(NewName,Name,ASIZE(NewName)); // Here we set the random name part. sprintfw(PointToName(NewName),ASIZE(NewName),L"rtmp%d",I); // If such file is already exist, try next random name. if (FileExist(NULL,NewName)) *NewName=0; } // If we could not generate the name not used by any other file, we return. if (*NewName==0) return(false); // FastFind returns the name without path, but we need the fully qualified // name for renaming, so we use the path from file to create and long name // from existing file. wchar FullName[NM]; wcsncpyz(FullName,Name,ASIZE(FullName)); wcscpy(PointToName(FullName),PointToName(fd.NameW)); // Rename the existing file to randomly generated name. Normally it changes // the short name too. if (!MoveFileW(FullName,NewName)) return(false); // Now we need to create the temporary empty file with same name as // short name of our already existing file. We do it to occupy its previous // short name and not allow to use it again when renaming the file back to // its original long name. File KeepShortFile; bool Created=false; if (!FileExist(NULL,Name)) Created=KeepShortFile.Create(NULL,Name); // Now we rename the existing file from temporary name to original long name. // Since its previous short name is occupied by another file, it should // get another short name. MoveFileW(NewName,FullName); if (Created) { // Delete the temporary zero length file occupying the short name, KeepShortFile.Close(); KeepShortFile.Delete(); } // We successfully changed the short name. Maybe sometimes we'll simplify // this function by use of SetFileShortName Windows API call. // But SetFileShortName is not available in older Windows. return(true);}
开发者ID:pfalcon,项目名称:PhotoTvViewer,代码行数:78,
示例16: ListFileHeadervoid ListFileHeader(Archive &Arc,FileHeader &hd,bool &TitleShown,bool Verbose,bool Technical,bool Bare){ wchar *Name=hd.FileName; RARFORMAT Format=Arc.Format; if (Bare) { mprintf(L"%s/n",Name); return; } if (!TitleShown && !Technical) { if (Verbose) { mprintf(L"/n%ls",St(MListTitleV)); mprintf(L"/n----------- --------- -------- ----- ---------- ----- -------- ----"); } else { mprintf(L"/n%ls",St(MListTitleL)); mprintf(L"/n----------- --------- ---------- ----- ----"); } TitleShown=true; } wchar UnpSizeText[20],PackSizeText[20]; if (hd.UnpSize==INT64NDF) wcscpy(UnpSizeText,L"?"); else itoa(hd.UnpSize,UnpSizeText,ASIZE(UnpSizeText)); itoa(hd.PackSize,PackSizeText,ASIZE(PackSizeText)); wchar AttrStr[30]; if (hd.HeaderType==HEAD_SERVICE) swprintf(AttrStr,ASIZE(AttrStr),L"%cB",hd.Inherited ? 'I' : '.'); else ListFileAttr(hd.FileAttr,hd.HSType,AttrStr,ASIZE(AttrStr)); wchar RatioStr[10]; if (hd.SplitBefore && hd.SplitAfter) wcscpy(RatioStr,L"<->"); else if (hd.SplitBefore) wcscpy(RatioStr,L"<--"); else if (hd.SplitAfter) wcscpy(RatioStr,L"-->"); else swprintf(RatioStr,ASIZE(RatioStr),L"%d%%",ToPercentUnlim(hd.PackSize,hd.UnpSize)); wchar DateStr[50]; hd.mtime.GetText(DateStr,ASIZE(DateStr),Technical); if (Technical) { mprintf(L"/n%12s: %s",St(MListName),Name); bool FileBlock=hd.HeaderType==HEAD_FILE; if (!FileBlock && Arc.SubHead.CmpName(SUBHEAD_TYPE_STREAM)) { mprintf(L"/n%12ls: %ls",St(MListType),St(MListStream)); wchar StreamName[NM]; GetStreamNameNTFS(Arc,StreamName,ASIZE(StreamName)); mprintf(L"/n%12ls: %ls",St(MListTarget),StreamName); } else { const wchar *Type=St(FileBlock ? (hd.Dir ? MListDir:MListFile):MListService); if (hd.RedirType!=FSREDIR_NONE) switch(hd.RedirType) { case FSREDIR_UNIXSYMLINK: Type=St(MListUSymlink); break; case FSREDIR_WINSYMLINK: Type=St(MListWSymlink); break; case FSREDIR_JUNCTION: Type=St(MListJunction); break; case FSREDIR_HARDLINK: Type=St(MListHardlink); break; case FSREDIR_FILECOPY: Type=St(MListCopy); break; } mprintf(L"/n%12ls: %ls",St(MListType),Type); if (hd.RedirType!=FSREDIR_NONE) if (Format==RARFMT15) { char LinkTargetA[NM]; if (Arc.FileHead.Encrypted) { // Link data are encrypted. We would need to ask for password // and initialize decryption routine to display the link target. strncpyz(LinkTargetA,"*<-?->",ASIZE(LinkTargetA)); } else { int DataSize=(int)Min(hd.PackSize,ASIZE(LinkTargetA)-1);//.........这里部分代码省略.........
开发者ID:ccarpo,项目名称:ComicStreamer,代码行数:101,
示例17: FileCreatebool FileCreate(RAROptions *Cmd,File *NewFile,char *Name,wchar *NameW, OVERWRITE_MODE Mode,bool *UserReject,int64 FileSize, uint FileTime,bool WriteOnly){ if (UserReject!=NULL) *UserReject=false;#if defined(_WIN_ALL) && !defined(_WIN_CE) bool ShortNameChanged=false;#endif while (FileExist(Name,NameW)) {#if defined(_WIN_ALL) && !defined(_WIN_CE) if (!ShortNameChanged) { // Avoid the infinite loop if UpdateExistingShortName returns // the same name. ShortNameChanged=true; // Maybe our long name matches the short name of existing file. // Let's check if we can change the short name. wchar WideName[NM]; GetWideName(Name,NameW,WideName,ASIZE(WideName)); if (UpdateExistingShortName(WideName)) { if (Name!=NULL && *Name!=0) WideToChar(WideName,Name); if (NameW!=NULL && *NameW!=0) wcscpy(NameW,WideName); continue; } } // Allow short name check again. It is necessary, because rename and // autorename below can change the name, so we need to check it again. ShortNameChanged=false;#endif if (Mode==OVERWRITE_NONE) { if (UserReject!=NULL) *UserReject=true; return(false); } // Must be before Cmd->AllYes check or -y switch would override -or. if (Mode==OVERWRITE_AUTORENAME) { if (!GetAutoRenamedName(Name,NameW)) Mode=OVERWRITE_DEFAULT; continue; }#ifdef SILENT Mode=OVERWRITE_ALL;#endif // This check must be after OVERWRITE_AUTORENAME processing or -y switch // would override -or. if (Cmd->AllYes || Mode==OVERWRITE_ALL) break; if (Mode==OVERWRITE_DEFAULT || Mode==OVERWRITE_FORCE_ASK) { char NewName[NM]; wchar NewNameW[NM]; *NewNameW=0; eprintf(St(MFileExists),Name); int Choice=Ask(St(MYesNoAllRenQ)); if (Choice==1) break; if (Choice==2) { if (UserReject!=NULL) *UserReject=true; return(false); } if (Choice==3) { Cmd->Overwrite=OVERWRITE_ALL; break; } if (Choice==4) { if (UserReject!=NULL) *UserReject=true; Cmd->Overwrite=OVERWRITE_NONE; return(false); } if (Choice==5) {#ifndef GUI mprintf(St(MAskNewName));#ifdef _WIN_ALL File SrcFile; SrcFile.SetHandleType(FILE_HANDLESTD); int Size=SrcFile.Read(NewName,sizeof(NewName)-1); NewName[Size]=0; OemToCharA(NewName,NewName);#else if (fgets(NewName,sizeof(NewName),stdin)==NULL) {//.........这里部分代码省略.........
开发者ID:pfalcon,项目名称:PhotoTvViewer,代码行数:101,
示例18: ListArchivevoid ListArchive(CommandData *Cmd){ int64 SumPackSize=0,SumUnpSize=0; uint ArcCount=0,SumFileCount=0; bool Technical=(Cmd->Command[1]=='T'); bool ShowService=Technical && Cmd->Command[2]=='A'; bool Bare=(Cmd->Command[1]=='B'); bool Verbose=(Cmd->Command[0]=='V'); wchar ArcName[NM]; while (Cmd->GetArcName(ArcName,ASIZE(ArcName))) { if (Cmd->ManualPassword) Cmd->Password.Clean(); // Clean user entered password before processing next archive. Archive Arc(Cmd);#ifdef _WIN_ALL Arc.RemoveSequentialFlag();#endif if (!Arc.WOpen(ArcName)) continue; bool FileMatched=true; while (1) { int64 TotalPackSize=0,TotalUnpSize=0; uint FileCount=0; if (Arc.IsArchive(true)) { bool TitleShown=false; if (!Bare) { Arc.ViewComment(); mprintf(L"/n%s: %s",St(MListArchive),Arc.FileName); mprintf(L"/n%s: ",St(MListDetails)); uint SetCount=0; const wchar *Fmt=Arc.Format==RARFMT14 ? L"RAR 1.4":(Arc.Format==RARFMT15 ? L"RAR 4":L"RAR 5"); mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", Fmt); if (Arc.Solid) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListSolid)); if (Arc.SFXSize>0) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListSFX)); if (Arc.Volume) if (Arc.Format==RARFMT50) { // RAR 5.0 archives store the volume number in main header, // so it is already available now. if (SetCount++ > 0) mprintf(L", "); mprintf(St(MVolumeNumber),Arc.VolNumber+1); } else mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListVolume)); if (Arc.Protected) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListRR)); if (Arc.Locked) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListLock)); if (Arc.Encrypted) mprintf(L"%s%s", SetCount++ > 0 ? L", ":L"", St(MListEncHead)); mprintf(L"/n"); } wchar VolNumText[50]; *VolNumText=0; while(Arc.ReadHeader()>0) { HEADER_TYPE HeaderType=Arc.GetHeaderType(); if (HeaderType==HEAD_ENDARC) {#ifndef SFX_MODULE // Only RAR 1.5 archives store the volume number in end record. if (Arc.EndArcHead.StoreVolNumber && Arc.Format==RARFMT15) swprintf(VolNumText,ASIZE(VolNumText),L"%.10ls %d",St(MListVolume),Arc.VolNumber+1);#endif if (Technical && ShowService) { mprintf(L"/n%12ls: %ls",St(MListService),L"EOF"); if (*VolNumText!=0) mprintf(L"/n%12ls: %ls",St(MListFlags),VolNumText); mprintf(L"/n"); } break; } switch(HeaderType) { case HEAD_FILE: FileMatched=Cmd->IsProcessFile(Arc.FileHead)!=0; if (FileMatched) { ListFileHeader(Arc,Arc.FileHead,TitleShown,Verbose,Technical,Bare); if (!Arc.FileHead.SplitBefore) { TotalUnpSize+=Arc.FileHead.UnpSize; FileCount++; } TotalPackSize+=Arc.FileHead.PackSize; } break; case HEAD_SERVICE: if (FileMatched && !Bare) {//.........这里部分代码省略.........
开发者ID:ccarpo,项目名称:ComicStreamer,代码行数:101,
示例19: GetWin32void RarTime::GetLocal(RarLocalTime *lt){#ifdef _WIN_ALL FILETIME ft; GetWin32(&ft); FILETIME lft; if (WinNT() < WNT_VISTA) { // SystemTimeToTzSpecificLocalTime based code produces 1 hour error on XP. FileTimeToLocalFileTime(&ft,&lft); } else { // We use these functions instead of FileTimeToLocalFileTime according to // MSDN recommendation: "To account for daylight saving time // when converting a file time to a local time ..." SYSTEMTIME st1,st2; FileTimeToSystemTime(&ft,&st1); SystemTimeToTzSpecificLocalTime(NULL,&st1,&st2); SystemTimeToFileTime(&st2,&lft); // Correct precision loss (low 4 decimal digits) in FileTimeToSystemTime. FILETIME rft; SystemTimeToFileTime(&st1,&rft); int64 Corrected=INT32TO64(ft.dwHighDateTime,ft.dwLowDateTime)- INT32TO64(rft.dwHighDateTime,rft.dwLowDateTime)+ INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime); lft.dwLowDateTime=(DWORD)Corrected; lft.dwHighDateTime=(DWORD)(Corrected>>32); } SYSTEMTIME st; FileTimeToSystemTime(&lft,&st); lt->Year=st.wYear; lt->Month=st.wMonth; lt->Day=st.wDay; lt->Hour=st.wHour; lt->Minute=st.wMinute; lt->Second=st.wSecond; lt->wDay=st.wDayOfWeek; lt->yDay=lt->Day-1; static int mdays[12]={31,28,31,30,31,30,31,31,30,31,30,31}; for (uint I=1;I<lt->Month && I<=ASIZE(mdays);I++) lt->yDay+=mdays[I-1]; if (lt->Month>2 && IsLeapYear(lt->Year)) lt->yDay++; st.wMilliseconds=0; FILETIME zft; SystemTimeToFileTime(&st,&zft); // Calculate the time reminder, which is the part of time smaller // than 1 second, represented in 100-nanosecond intervals. lt->Reminder=INT32TO64(lft.dwHighDateTime,lft.dwLowDateTime)- INT32TO64(zft.dwHighDateTime,zft.dwLowDateTime);#else time_t ut=GetUnix(); struct tm *t; t=localtime(&ut); lt->Year=t->tm_year+1900; lt->Month=t->tm_mon+1; lt->Day=t->tm_mday; lt->Hour=t->tm_hour; lt->Minute=t->tm_min; lt->Second=t->tm_sec; lt->Reminder=itime % 10000000; lt->wDay=t->tm_wday; lt->yDay=t->tm_yday;#endif}
开发者ID:Cpasjuste,项目名称:nzbm,代码行数:74,
示例20: UnpInitDatavoid Unpack::Unpack29(bool Solid){ static unsigned char LDecode[]={0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224}; static unsigned char LBits[]= {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5}; static int DDecode[DC]; static byte DBits[DC]; static int DBitLengthCounts[]= {4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,14,0,12}; static unsigned char SDDecode[]={0,4,8,16,32,64,128,192}; static unsigned char SDBits[]= {2,2,3, 4, 5, 6, 6, 6}; unsigned int Bits; if (DDecode[1]==0) { int Dist=0,BitLength=0,Slot=0; for (int I=0;I<ASIZE(DBitLengthCounts);I++,BitLength++) for (int J=0;J<DBitLengthCounts[I];J++,Slot++,Dist+=(1<<BitLength)) { DDecode[Slot]=Dist; DBits[Slot]=BitLength; } } FileExtracted=true; if (!Suspended) { UnpInitData(Solid); if (!UnpReadBuf30()) return; if ((!Solid || !TablesRead) && !ReadTables30()) return; } while (true) { UnpPtr&=MaxWinMask; if (Inp.InAddr>ReadBorder) { if (!UnpReadBuf30()) break; } if (((WrPtr-UnpPtr) & MaxWinMask)<260 && WrPtr!=UnpPtr) { UnpWriteBuf30(); if (WrittenFileSize>DestUnpSize) return; if (Suspended) { FileExtracted=false; return; } } if (UnpBlockType==BLOCK_PPM) { // Here speed is critical, so we do not use SafePPMDecodeChar, // because sometimes even the inline function can introduce // some additional penalty. int Ch=PPM.DecodeChar(); if (Ch==-1) // Corrupt PPM data found. { PPM.CleanUp(); // Reset possibly corrupt PPM data structures. UnpBlockType=BLOCK_LZ; // Set faster and more fail proof LZ mode. break; } if (Ch==PPMEscChar) { int NextCh=SafePPMDecodeChar(); if (NextCh==0) // End of PPM encoding. { if (!ReadTables30()) break; continue; } if (NextCh==-1) // Corrupt PPM data found. break; if (NextCh==2) // End of file in PPM mode. break; if (NextCh==3) // Read VM code. { if (!ReadVMCodePPM()) break; continue; } if (NextCh==4) // LZ inside of PPM. { unsigned int Distance=0,Length; bool Failed=false; for (int I=0;I<4 && !Failed;I++) { int Ch=SafePPMDecodeChar(); if (Ch==-1) Failed=true; else if (I==3) Length=(byte)Ch; else Distance=(Distance<<8)+(byte)Ch; } if (Failed)//.........这里部分代码省略.........
开发者ID:ccarpo,项目名称:ComicStreamer,代码行数:101,
示例21: GenArcNamestatic void GenArcName(wchar *ArcName,const wchar *GenerateMask,uint ArcNumber,bool &ArcNumPresent){ bool Prefix=false; if (*GenerateMask=='+') { Prefix=true; // Add the time string before the archive name. GenerateMask++; // Skip '+' in the beginning of time mask. } wchar Mask[MAX_GENERATE_MASK]; wcsncpyz(Mask,*GenerateMask!=0 ? GenerateMask:L"yyyymmddhhmmss",ASIZE(Mask)); bool QuoteMode=false,Hours=false; for (uint I=0;Mask[I]!=0;I++) { if (Mask[I]=='{' || Mask[I]=='}') { QuoteMode=(Mask[I]=='{'); continue; } if (QuoteMode) continue; int CurChar=toupperw(Mask[I]); if (CurChar=='H') Hours=true; if (Hours && CurChar=='M') { // Replace minutes with 'I'. We use 'M' both for months and minutes, // so we treat as minutes only those 'M' which are found after hours. Mask[I]='I'; } if (CurChar=='N') { uint Digits=GetDigits(ArcNumber); uint NCount=0; while (toupperw(Mask[I+NCount])=='N') NCount++; // Here we ensure that we have enough 'N' characters to fit all digits // of archive number. We'll replace them by actual number later // in this function. if (NCount<Digits) { wmemmove(Mask+I+Digits,Mask+I+NCount,wcslen(Mask+I+NCount)+1); wmemset(Mask+I,'N',Digits); } I+=Max(Digits,NCount)-1; ArcNumPresent=true; continue; } } RarTime CurTime; CurTime.SetCurrentTime(); RarLocalTime rlt; CurTime.GetLocal(&rlt); wchar Ext[NM],*Dot=GetExt(ArcName); *Ext=0; if (Dot==NULL) wcscpy(Ext,*PointToName(ArcName)==0 ? L".rar":L""); else { wcsncpyz(Ext,Dot,ASIZE(Ext)); *Dot=0; } int WeekDay=rlt.wDay==0 ? 6:rlt.wDay-1; int StartWeekDay=rlt.yDay-WeekDay; if (StartWeekDay<0) if (StartWeekDay<=-4) StartWeekDay+=IsLeapYear(rlt.Year-1) ? 366:365; else StartWeekDay=0; int CurWeek=StartWeekDay/7+1; if (StartWeekDay%7>=4) CurWeek++; char Field[10][6]; sprintf(Field[0],"%04d",rlt.Year); sprintf(Field[1],"%02d",rlt.Month); sprintf(Field[2],"%02d",rlt.Day); sprintf(Field[3],"%02d",rlt.Hour); sprintf(Field[4],"%02d",rlt.Minute); sprintf(Field[5],"%02d",rlt.Second); sprintf(Field[6],"%02d",CurWeek); sprintf(Field[7],"%d",WeekDay+1); sprintf(Field[8],"%03d",rlt.yDay+1); sprintf(Field[9],"%05d",ArcNumber); const wchar *MaskChars=L"YMDHISWAEN"; int CField[sizeof(Field)/sizeof(Field[0])]; memset(CField,0,sizeof(CField)); QuoteMode=false; for (int I=0;Mask[I]!=0;I++) { if (Mask[I]=='{' || Mask[I]=='}')//.........这里部分代码省略.........
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:101,
示例22: returnsize_t Archive::ReadHeader(){ // Once we failed to decrypt an encrypted block, there is no reason to // attempt to do it further. We'll never be successful and only generate // endless errors. if (FailedHeaderDecryption) return 0; CurBlockPos=Tell();#ifndef SFX_MODULE if (OldFormat) return(ReadOldHeader());#endif RawRead Raw(this); bool Decrypt=Encrypted && CurBlockPos>=(int64)SFXSize+SIZEOF_MARKHEAD+SIZEOF_NEWMHD; if (Decrypt) {#if defined(SHELL_EXT) || defined(RAR_NOCRYPT) return(0);#else if (Read(HeadersSalt,SALT_SIZE)!=SALT_SIZE) { UnexpEndArcMsg(); return(0); } if (*Cmd->Password==0) {#ifdef RARDLL char PasswordA[MAXPASSWORD]; if (Cmd->Callback==NULL || Cmd->Callback(UCM_NEEDPASSWORD,Cmd->UserData,(LPARAM)PasswordA,ASIZE(PasswordA))==-1) { Close(); ErrHandler.Exit(USER_BREAK); } GetWideName(PasswordA,NULL,Cmd->Password,ASIZE(Cmd->Password));#else if (!GetPassword(PASSWORD_ARCHIVE,FileName,FileNameW,Cmd->Password,ASIZE(Cmd->Password))) { Close(); ErrHandler.Exit(USER_BREAK); }#endif } HeadersCrypt.SetCryptKeys(Cmd->Password,HeadersSalt,false,false,NewMhd.EncryptVer>=36); Raw.SetCrypt(&HeadersCrypt);#endif } Raw.Read(SIZEOF_SHORTBLOCKHEAD); if (Raw.Size()==0) { UnexpEndArcMsg(); return(0); } Raw.Get(ShortBlock.HeadCRC); byte HeadType; Raw.Get(HeadType); ShortBlock.HeadType=(HEADER_TYPE)HeadType; Raw.Get(ShortBlock.Flags); Raw.Get(ShortBlock.HeadSize); if (ShortBlock.HeadSize<SIZEOF_SHORTBLOCKHEAD) {#ifndef SHELL_EXT Log(FileName,St(MLogFileHead),"???");#endif BrokenFileHeader=true; ErrHandler.SetErrorCode(CRC_ERROR); return(0); } if (ShortBlock.HeadType==COMM_HEAD) { // Old style (up to RAR 2.9) comment header embedded into main // or file header. We must not read the entire ShortBlock.HeadSize here // to not break the comment processing logic later. Raw.Read(SIZEOF_COMMHEAD-SIZEOF_SHORTBLOCKHEAD); } else if (ShortBlock.HeadType==MAIN_HEAD && (ShortBlock.Flags & MHD_COMMENT)!=0) { // Old style (up to RAR 2.9) main archive comment embedded into // the main archive header found. While we can read the entire // ShortBlock.HeadSize here and remove this part of "if", it would be // waste of memory, because we'll read and process this comment data // in other function anyway and we do not need them here now. Raw.Read(SIZEOF_NEWMHD-SIZEOF_SHORTBLOCKHEAD); } else Raw.Read(ShortBlock.HeadSize-SIZEOF_SHORTBLOCKHEAD); NextBlockPos=CurBlockPos+ShortBlock.HeadSize; switch(ShortBlock.HeadType) //this is where the type of header that is found, can be executed properly {//.........这里部分代码省略.........
开发者ID:ajnelson,项目名称:bulk_extractor,代码行数:101,
示例23: ExtractStreamsNewvoid ExtractStreamsNew(Archive& Arc, char* FileName, wchar* FileNameW){ if (!WinNT()) return; wchar NameW[NM]; if (FileNameW != NULL && *FileNameW != 0) wcscpy(NameW, FileNameW); else CharToWide(FileName, NameW); wchar StreamNameW[NM + 2]; if (NameW[0] != 0 && NameW[1] == 0) { wcscpy(StreamNameW, L".//"); wcscpy(StreamNameW + 2, NameW); } else wcscpy(StreamNameW, NameW); wchar* DestName = StreamNameW + wcslen(StreamNameW); byte* SrcName = &Arc.SubHead.SubData[0]; size_t DestSize = Arc.SubHead.SubData.Size() / 2; if (wcslen(StreamNameW) + DestSize >= ASIZE(StreamNameW)) {#if !defined(SILENT) && !defined(SFX_MODULE) Log(Arc.FileName, St(MStreamBroken), FileName);#endif ErrHandler.SetErrorCode(CRC_ERROR); return; } RawToWide(SrcName, DestName, DestSize); DestName[DestSize] = 0; if (*DestName != ':') {#if !defined(SILENT) && !defined(SFX_MODULE) Log(Arc.FileName, St(MStreamBroken), FileName);#endif ErrHandler.SetErrorCode(CRC_ERROR); return; } ConvertPath(DestName + 1, DestName + 1); FindData fd; bool Found = FindFile::FastFind(FileName, FileNameW, &fd); if (fd.FileAttr & FILE_ATTRIBUTE_READONLY) SetFileAttr(FileName, FileNameW, fd.FileAttr & ~FILE_ATTRIBUTE_READONLY); char StreamName[NM]; WideToChar(StreamNameW, StreamName); File CurFile; if (CurFile.WCreate(StreamName, StreamNameW) && Arc.ReadSubData(NULL, &CurFile)) CurFile.Close(); File HostFile; if (Found && HostFile.Open(FileName, FileNameW, true, true)) SetFileTime(HostFile.GetHandle(), &fd.ftCreationTime, &fd.ftLastAccessTime, &fd.ftLastWriteTime); // Restoring original file attributes. Important if file was read only // or did not have "Archive" attribute SetFileAttr(FileName, FileNameW, fd.FileAttr);}
开发者ID:Tyf0n,项目名称:Rar_crack,代码行数:73,
示例24: DllVolChangebool DllVolChange(RAROptions *Cmd,wchar *NextName,size_t NameSize){ bool DllVolChanged=false,DllVolAborted=false; if (Cmd->Callback!=NULL) { wchar CurName[NM]; wcscpy(CurName,NextName); if (Cmd->Callback(UCM_CHANGEVOLUMEW,Cmd->UserData,(LPARAM)NextName,RAR_VOL_ASK)==-1) DllVolAborted=true; else if (wcscmp(CurName,NextName)!=0) DllVolChanged=true; else { char NextNameA[NM]; WideToChar(NextName,NextNameA,ASIZE(NextNameA)); if (Cmd->Callback(UCM_CHANGEVOLUME,Cmd->UserData,(LPARAM)NextNameA,RAR_VOL_ASK)==-1) DllVolAborted=true; else { CharToWide(NextNameA,NextName,NameSize); if (wcscmp(CurName,NextName)!=0) DllVolChanged=true; } } } if (!DllVolChanged && Cmd->ChangeVolProc!=NULL) { char NextNameA[NM]; WideToChar(NextName,NextNameA,ASIZE(NextNameA)); // Here we preserve ESP value. It is necessary for those developers, // who still define ChangeVolProc callback as "C" type function, // even though in year 2001 we announced in unrar.dll whatsnew.txt // that it will be PASCAL type (for compatibility with Visual Basic).#if defined(_MSC_VER)#ifndef _WIN_64 __asm mov ebx,esp#endif#elif defined(_WIN_ALL) && defined(__BORLANDC__) _EBX=_ESP;#endif int RetCode=Cmd->ChangeVolProc(NextNameA,RAR_VOL_ASK); // Restore ESP after ChangeVolProc with wrongly defined calling // convention broken it.#if defined(_MSC_VER)#ifndef _WIN_64 __asm mov esp,ebx#endif#elif defined(_WIN_ALL) && defined(__BORLANDC__) _ESP=_EBX;#endif if (RetCode==0) DllVolAborted=true; else CharToWide(NextNameA,NextName,ASIZE(NextName)); } // We quit only on 'abort' condition, but not on 'name not changed'. // It is legitimate for program to return the same name when waiting // for currently non-existent volume. if (DllVolAborted) { Cmd->DllError=ERAR_EOPEN; return false; } return true;}
开发者ID:KhR0N1K,项目名称:mpc-hc,代码行数:69,
示例25: memcmpvoid CryptData::SetKey30(bool Encrypt,SecPassword *Password,const wchar *PwdW,const byte *Salt){ byte AESKey[16],AESInit[16]; bool Cached=false; for (uint I=0;I<ASIZE(KDF3Cache);I++) if (KDF3Cache[I].Pwd==*Password && (Salt==NULL && !KDF3Cache[I].SaltPresent || Salt!=NULL && KDF3Cache[I].SaltPresent && memcmp(KDF3Cache[I].Salt,Salt,SIZE_SALT30)==0)) { memcpy(AESKey,KDF3Cache[I].Key,sizeof(AESKey)); memcpy(AESInit,KDF3Cache[I].Init,sizeof(AESInit)); Cached=true; break; } if (!Cached) { byte RawPsw[2*MAXPASSWORD+SIZE_SALT30]; WideToRaw(PwdW,RawPsw,ASIZE(RawPsw)); size_t RawLength=2*wcslen(PwdW); if (Salt!=NULL) { memcpy(RawPsw+RawLength,Salt,SIZE_SALT30); RawLength+=SIZE_SALT30; } sha1_context c; sha1_init(&c); const int HashRounds=0x40000; for (int I=0;I<HashRounds;I++) { sha1_process( &c, RawPsw, RawLength, false); byte PswNum[3]; PswNum[0]=(byte)I; PswNum[1]=(byte)(I>>8); PswNum[2]=(byte)(I>>16); sha1_process( &c, PswNum, 3, false); if (I%(HashRounds/16)==0) { sha1_context tempc=c; uint32 digest[5]; sha1_done( &tempc, digest, false); AESInit[I/(HashRounds/16)]=(byte)digest[4]; } } uint32 digest[5]; sha1_done( &c, digest, false); for (int I=0;I<4;I++) for (int J=0;J<4;J++) AESKey[I*4+J]=(byte)(digest[I]>>(J*8)); KDF3Cache[KDF3CachePos].Pwd=*Password; if ((KDF3Cache[KDF3CachePos].SaltPresent=(Salt!=NULL))==true) memcpy(KDF3Cache[KDF3CachePos].Salt,Salt,SIZE_SALT30); memcpy(KDF3Cache[KDF3CachePos].Key,AESKey,sizeof(AESKey)); memcpy(KDF3Cache[KDF3CachePos].Init,AESInit,sizeof(AESInit)); KDF3CachePos=(KDF3CachePos+1)%ASIZE(KDF3Cache); cleandata(RawPsw,sizeof(RawPsw)); }
开发者ID:GetEnvy,项目名称:Envy,代码行数:61,
示例26: MergeArchivebool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,wchar Command){ RAROptions *Cmd=Arc.GetRAROptions(); HEADER_TYPE HeaderType=Arc.GetHeaderType(); FileHeader *hd=HeaderType==HEAD_SERVICE ? &Arc.SubHead:&Arc.FileHead; bool SplitHeader=(HeaderType==HEAD_FILE || HeaderType==HEAD_SERVICE) && hd->SplitAfter; if (DataIO!=NULL && SplitHeader) { bool PackedHashPresent=Arc.Format==RARFMT50 || hd->UnpVer>=20 && hd->FileHash.CRC32!=0xffffffff; if (PackedHashPresent && !DataIO->PackedDataHash.Cmp(&hd->FileHash,hd->UseHashKey ? hd->HashKey:NULL)) uiMsg(UIERROR_CHECKSUMPACKED, Arc.FileName, hd->FileName); } int64 PosBeforeClose=Arc.Tell(); if (DataIO!=NULL) DataIO->ProcessedArcSize+=Arc.FileLength(); Arc.Close(); wchar NextName[NM]; wcscpy(NextName,Arc.FileName); NextVolumeName(NextName,ASIZE(NextName),!Arc.NewNumbering);#if !defined(SFX_MODULE) && !defined(RARDLL) bool RecoveryDone=false;#endif bool FailedOpen=false,OldSchemeTested=false;#if !defined(GUI) && !defined(SILENT) // In -vp mode we force the pause before next volume even if it is present // and even if we are on the hard disk. It is important when user does not // want to process partially downloaded volumes preliminary. if (Cmd->VolumePause && !uiAskNextVolume(NextName,ASIZE(NextName))) FailedOpen=true;#endif uint OpenMode = Cmd->OpenShared ? FMF_OPENSHARED : 0; if (!FailedOpen) while (!Arc.Open(NextName,OpenMode)) { // We need to open a new volume which size was not calculated // in total size before, so we cannot calculate the total progress // anymore. Let's reset the total size to zero and stop // the total progress. if (DataIO!=NULL) DataIO->TotalArcSize=0; if (!OldSchemeTested) { // Checking for new style volumes renamed by user to old style // name format. Some users did it for unknown reason. wchar AltNextName[NM]; wcscpy(AltNextName,Arc.FileName); NextVolumeName(AltNextName,ASIZE(AltNextName),true); OldSchemeTested=true; if (Arc.Open(AltNextName,OpenMode)) { wcscpy(NextName,AltNextName); break; } }#ifdef RARDLL if (!DllVolChange(Cmd,NextName,ASIZE(NextName))) { FailedOpen=true; break; }#else // !RARDLL#ifndef SFX_MODULE if (!RecoveryDone) { RecVolumesRestore(Cmd,Arc.FileName,true); RecoveryDone=true; continue; }#endif#ifndef GUI if (!Cmd->VolumePause && !IsRemovable(NextName)) { FailedOpen=true; break; }#endif#ifndef SILENT if (Cmd->AllYes || !uiAskNextVolume(NextName,ASIZE(NextName)))#endif { FailedOpen=true; break; }//.........这里部分代码省略.........
开发者ID:KhR0N1K,项目名称:mpc-hc,代码行数:101,
示例27: mainint main(int argc, char *argv[]){#ifdef _UNIX setlocale(LC_ALL,"");#endif InitConsole(); ErrHandler.SetSignalHandlers(true);#ifdef SFX_MODULE wchar ModuleName[NM];#ifdef _WIN_ALL GetModuleFileName(NULL,ModuleName,ASIZE(ModuleName));#else CharToWide(argv[0],ModuleName,ASIZE(ModuleName));#endif#endif#ifdef _WIN_ALL SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT|SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);#endif#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT) // Must be initialized, normal initialization can be skipped in case of // exception. bool ShutdownOnClose=false;#endif try { CommandData *Cmd=new CommandData;#ifdef SFX_MODULE wcscpy(Cmd->Command,L"X"); char *Switch=NULL;#ifdef _SFX_RTL_ char *CmdLine=GetCommandLineA(); if (CmdLine!=NULL && *CmdLine=='/"') CmdLine=strchr(CmdLine+1,'/"'); if (CmdLine!=NULL && (CmdLine=strpbrk(CmdLine," /"))!=NULL) { while (IsSpace(*CmdLine)) CmdLine++; Switch=CmdLine; }#else Switch=argc>1 ? argv[1]:NULL;#endif if (Switch!=NULL && Cmd->IsSwitch(Switch[0])) { int UpperCmd=etoupper(Switch[1]); switch(UpperCmd) { case 'T': case 'V': Cmd->Command[0]=UpperCmd; break; case '?': Cmd->OutHelp(RARX_SUCCESS); break; } } Cmd->AddArcName(ModuleName); Cmd->ParseDone();#else // !SFX_MODULE Cmd->ParseCommandLine(true,argc,argv); if (!Cmd->ConfigDisabled) { Cmd->ReadConfig(); Cmd->ParseEnvVar(); } Cmd->ParseCommandLine(false,argc,argv);#endif#if defined(_WIN_ALL) && !defined(SFX_MODULE) && !defined(SHELL_EXT) ShutdownOnClose=Cmd->Shutdown;#endif InitConsoleOptions(Cmd->MsgStream,Cmd->Sound); InitLogOptions(Cmd->LogName,Cmd->ErrlogCharset); ErrHandler.SetSilent(Cmd->AllYes || Cmd->MsgStream==MSG_NULL); ErrHandler.SetShutdown(Cmd->Shutdown); Cmd->OutTitle(); Cmd->ProcessCommand(); delete Cmd; } catch (RAR_EXIT ErrCode) { ErrHandler.SetErrorCode(ErrCode); } catch (std::bad_alloc) { ErrHandler.MemoryErrorMsg(); ErrHandler.SetErrorCode(RARX_MEMORY); } catch (...)//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:unrar,代码行数:101,
示例28: CreateReparsePointbool CreateReparsePoint(CommandData *Cmd,const wchar *Name,FileHeader *hd){ static bool PrivSet=false; if (!PrivSet) { SetPrivilege(SE_RESTORE_NAME); // Not sure if we really need it, but let's request anyway. SetPrivilege(SE_CREATE_SYMBOLIC_LINK_NAME); PrivSet=true; } const DWORD BufSize=sizeof(REPARSE_DATA_BUFFER)+2*NM+1024; Array<byte> Buf(BufSize); REPARSE_DATA_BUFFER *rdb=(REPARSE_DATA_BUFFER *)&Buf[0]; wchar SubstName[NM]; wcsncpyz(SubstName,hd->RedirName,ASIZE(SubstName)); size_t SubstLength=unrar_wcslen(SubstName); wchar PrintName[NM],*PrintNameSrc=SubstName,*PrintNameDst=PrintName; bool WinPrefix=unrar_wcsncmp(PrintNameSrc,L"//??//",4)==0; if (WinPrefix) PrintNameSrc+=4; if (WinPrefix && unrar_wcsncmp(PrintNameSrc,L"UNC//",4)==0) { *(PrintNameDst++)='//'; // Insert second / in beginning of share name. PrintNameSrc+=3; } unrar_wcscpy(PrintNameDst,PrintNameSrc); size_t PrintLength=unrar_wcslen(PrintName); bool AbsPath=WinPrefix; // IsFullPath is not really needed here, AbsPath check is enough. // We added it just for extra safety, in case some Windows version would // allow to create absolute targets with SYMLINK_FLAG_RELATIVE. if (!Cmd->AbsoluteLinks && (AbsPath || IsFullPath(hd->RedirName) || !IsRelativeSymlinkSafe(hd->FileName,hd->RedirName))) return false;#ifndef NOFILECREATE CreatePath(Name,true); // 'DirTarget' check is important for Unix symlinks to directories. // Unix symlinks do not have their own 'directory' attribute. if (hd->Dir || hd->DirTarget) { if (!CreateDirectory(Name,NULL)) return false; } else { HANDLE hFile=CreateFile(Name,GENERIC_WRITE,0,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL); if (hFile == INVALID_HANDLE_VALUE) return false; CloseHandle(hFile); }#endif if (hd->RedirType==FSREDIR_JUNCTION) { rdb->ReparseTag=IO_REPARSE_TAG_MOUNT_POINT; rdb->ReparseDataLength=USHORT( sizeof(rdb->MountPointReparseBuffer.SubstituteNameOffset)+ sizeof(rdb->MountPointReparseBuffer.SubstituteNameLength)+ sizeof(rdb->MountPointReparseBuffer.PrintNameOffset)+ sizeof(rdb->MountPointReparseBuffer.PrintNameLength)+ (SubstLength+1)*sizeof(WCHAR)+(PrintLength+1)*sizeof(WCHAR)); rdb->Reserved=0; rdb->MountPointReparseBuffer.SubstituteNameOffset=0; rdb->MountPointReparseBuffer.SubstituteNameLength=USHORT(SubstLength*sizeof(WCHAR)); unrar_wcscpy(rdb->MountPointReparseBuffer.PathBuffer,SubstName); rdb->MountPointReparseBuffer.PrintNameOffset=USHORT((SubstLength+1)*sizeof(WCHAR)); rdb->MountPointReparseBuffer.PrintNameLength=USHORT(PrintLength*sizeof(WCHAR)); unrar_wcscpy(rdb->MountPointReparseBuffer.PathBuffer+SubstLength+1,PrintName); } else if (hd->RedirType==FSREDIR_WINSYMLINK || hd->RedirType==FSREDIR_UNIXSYMLINK) { rdb->ReparseTag=IO_REPARSE_TAG_SYMLINK; rdb->ReparseDataLength=USHORT( sizeof(rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset)+ sizeof(rdb->SymbolicLinkReparseBuffer.SubstituteNameLength)+ sizeof(rdb->SymbolicLinkReparseBuffer.PrintNameOffset)+ sizeof(rdb->SymbolicLinkReparseBuffer.PrintNameLength)+ sizeof(rdb->SymbolicLinkReparseBuffer.Flags)+ (SubstLength+1)*sizeof(WCHAR)+(PrintLength+1)*sizeof(WCHAR)); rdb->Reserved=0; rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset=0; rdb->SymbolicLinkReparseBuffer.SubstituteNameLength=USHORT(SubstLength*sizeof(WCHAR)); unrar_wcscpy(rdb->SymbolicLinkReparseBuffer.PathBuffer,SubstName); rdb->SymbolicLinkReparseBuffer.PrintNameOffset=USHORT((SubstLength+1)*sizeof(WCHAR)); rdb->SymbolicLinkReparseBuffer.PrintNameLength=USHORT(PrintLength*sizeof(WCHAR)); unrar_wcscpy(rdb->SymbolicLinkReparseBuffer.PathBuffer+SubstLength+1,PrintName); rdb->SymbolicLinkReparseBuffer.Flags=AbsPath ? 0:SYMLINK_FLAG_RELATIVE;//.........这里部分代码省略.........
开发者ID:devvit,项目名称:comicsreader,代码行数:101,
示例29: MergeArchivebool MergeArchive(Archive &Arc,ComprDataIO *DataIO,bool ShowFileName,char Command){ RAROptions *Cmd=Arc.GetRAROptions(); int HeaderType=Arc.GetHeaderType(); FileHeader *hd=HeaderType==NEWSUB_HEAD ? &Arc.SubHead:&Arc.NewLhd; bool SplitHeader=(HeaderType==FILE_HEAD || HeaderType==NEWSUB_HEAD) && (hd->Flags & LHD_SPLIT_AFTER)!=0; if (DataIO!=NULL && SplitHeader && hd->UnpVer>=20 && hd->FileCRC!=0xffffffff && DataIO->PackedCRC!=~hd->FileCRC) { Log(Arc.FileName,St(MDataBadCRC),hd->FileName,Arc.FileName); } int64 PosBeforeClose=Arc.Tell(); if (DataIO!=NULL) DataIO->ProcessedArcSize+=Arc.FileLength(); Arc.Close(); char NextName[NM]; wchar NextNameW[NM]; strcpy(NextName,Arc.FileName); strcpyw(NextNameW,Arc.FileNameW); NextVolumeName(NextName,NextNameW,ASIZE(NextName),(Arc.NewMhd.Flags & MHD_NEWNUMBERING)==0 || Arc.OldFormat);#if !defined(SFX_MODULE) && !defined(RARDLL) bool RecoveryDone=false;#endif bool FailedOpen=false,OldSchemeTested=false; while (!Arc.Open(NextName,NextNameW)) { // We need to open a new volume which size was not calculated // in total size before, so we cannot calculate the total progress // anymore. Let's reset the total size to zero and stop // the total progress. if (DataIO!=NULL) DataIO->TotalArcSize=0; if (!OldSchemeTested) { // Checking for new style volumes renamed by user to old style // name format. Some users did it for unknown reason. char AltNextName[NM]; wchar AltNextNameW[NM]; strcpy(AltNextName,Arc.FileName); strcpyw(AltNextNameW,Arc.FileNameW); NextVolumeName(AltNextName,AltNextNameW,ASIZE(AltNextName),true); OldSchemeTested=true; if (Arc.Open(AltNextName,AltNextNameW)) { strcpy(NextName,AltNextName); strcpyw(NextNameW,AltNextNameW); break; } }#ifdef RARDLL if (Cmd->Callback==NULL && Cmd->ChangeVolProc==NULL || Cmd->Callback!=NULL && Cmd->Callback(UCM_CHANGEVOLUME,Cmd->UserData,(LPARAM)NextName,RAR_VOL_ASK)==-1) { Cmd->DllError=ERAR_EOPEN; FailedOpen=true; break; } if (Cmd->ChangeVolProc!=NULL) { // Here we preserve ESP value. It is necessary for those developers, // who still define ChangeVolProc callback as "C" type function, // even though in year 2001 we announced in unrar.dll whatsnew.txt // that it will be PASCAL type (for compatibility with Visual Basic).#if defined(_MSC_VER)#ifndef _M_X64 __asm mov ebx,esp#endif#elif defined(_WIN_32) && defined(__BORLANDC__) _EBX=_ESP;#endif int RetCode=Cmd->ChangeVolProc(NextName,RAR_VOL_ASK); // Restore ESP after ChangeVolProc with wrongly defined calling // convention broken it.#if defined(_MSC_VER)#ifndef _M_X64 __asm mov esp,ebx#endif#elif defined(_WIN_32) && defined(__BORLANDC__) _ESP=_EBX;#endif if (RetCode==0) { Cmd->DllError=ERAR_EOPEN; FailedOpen=true; break; } }#else // RARDLL//.........这里部分代码省略.........
开发者ID:604339917,项目名称:Common_Iphone,代码行数:101,
示例30: set_frame_menubarvoidset_frame_menubar (struct frame *f, bool first_time, bool deep_p){ HMENU menubar_widget = f->output_data.w32->menubar_widget; Lisp_Object items; widget_value *wv, *first_wv, *prev_wv = 0; int i, last_i; int *submenu_start, *submenu_end; int *submenu_top_level_items, *submenu_n_panes; /* We must not change the menubar when actually in use. */ if (f->output_data.w32->menubar_active) return; XSETFRAME (Vmenu_updating_frame, f); if (! menubar_widget) deep_p = true; if (deep_p) { /* Make a widget-value tree representing the entire menu trees. */ struct buffer *prev = current_buffer; Lisp_Object buffer; ptrdiff_t specpdl_count = SPECPDL_INDEX (); int previous_menu_items_used = f->menu_bar_items_used; Lisp_Object *previous_items = (Lisp_Object *) alloca (previous_menu_items_used * word_size); /* If we are making a new widget, its contents are empty, do always reinitialize them. */ if (! menubar_widget) previous_menu_items_used = 0; buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents; specbind (Qinhibit_quit, Qt); /* Don't let the debugger step into this code because it is not reentrant. */ specbind (Qdebug_on_next_call, Qnil); record_unwind_save_match_data (); if (NILP (Voverriding_local_map_menu_flag)) { specbind (Qoverriding_terminal_local_map, Qnil); specbind (Qoverriding_local_map, Qnil); } set_buffer_internal_1 (XBUFFER (buffer)); /* Run the hooks. */ safe_run_hooks (Qactivate_menubar_hook); safe_run_hooks (Qmenu_bar_update_hook); fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f))); items = FRAME_MENU_BAR_ITEMS (f); /* Save the frame's previous menu bar contents data. */ if (previous_menu_items_used) memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents, previous_menu_items_used * word_size); /* Fill in menu_items with the current menu bar contents. This can evaluate Lisp code. */ save_menu_items (); menu_items = f->menu_bar_vector; menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; submenu_start = (int *) alloca (ASIZE (items) * sizeof (int)); submenu_end = (int *) alloca (ASIZE (items) * sizeof (int)); submenu_n_panes = (int *) alloca (ASIZE (items) * sizeof (int)); submenu_top_level_items = (int *) alloca (ASIZE (items) * sizeof (int)); init_menu_items (); for (i = 0; i < ASIZE (items); i += 4) { Lisp_Object key, string, maps; last_i = i; key = AREF (items, i); string = AREF (items, i + 1); maps = AREF (items, i + 2); if (NILP (string)) break; submenu_start[i] = menu_items_used; menu_items_n_panes = 0; submenu_top_level_items[i] = parse_single_submenu (key, string, maps); submenu_n_panes[i] = menu_items_n_panes; submenu_end[i] = menu_items_used; } finish_menu_items (); /* Convert menu_items into widget_value trees//.........这里部分代码省略.........
开发者ID:Hooman3,项目名称:emacs,代码行数:101,
注:本文中的ASIZE函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ASL_GET_PEER_NODE函数代码示例 C++ ASIO_TEST_CASE函数代码示例 |