您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ wcsncpyz函数代码示例

51自学网 2021-06-03 09:54:02
  C++
这篇教程C++ wcsncpyz函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中wcsncpyz函数的典型用法代码示例。如果您正苦于以下问题:C++ wcsncpyz函数的具体用法?C++ wcsncpyz怎么用?C++ wcsncpyz使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了wcsncpyz函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GenerateArchiveName

void GenerateArchiveName(wchar *ArcName,size_t MaxSize,const wchar *GenerateMask,bool Archiving){  // Must be enough space for archive name plus all stuff in mask plus  // extra overhead produced by mask 'N' (archive number) characters.  // One 'N' character can result in several numbers if we process more  // than 9 archives.  wchar NewName[NM+MAX_GENERATE_MASK+20];  uint ArcNumber=1;  while (true) // Loop for 'N' (archive number) processing.  {    wcsncpyz(NewName,ArcName,ASIZE(NewName));        bool ArcNumPresent=false;    GenArcName(NewName,GenerateMask,ArcNumber,ArcNumPresent);        if (!ArcNumPresent)      break;    if (!FileExist(NewName))    {      if (!Archiving && ArcNumber>1)      {        // If we perform non-archiving operation, we need to use the last        // existing archive before the first unused name. So we generate        // the name for (ArcNumber-1) below.        wcsncpyz(NewName,NullToEmpty(ArcName),ASIZE(NewName));        GenArcName(NewName,GenerateMask,ArcNumber-1,ArcNumPresent);      }      break;    }    ArcNumber++;  }  wcsncpyz(ArcName,NewName,MaxSize);}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:35,


示例2: EnumConfigPaths

bool EnumConfigPaths(uint Number,wchar *Path,size_t MaxSize,bool Create){#ifdef _UNIX  static const wchar *ConfPath[]={    L"/etc", L"/etc/rar", L"/usr/lib", L"/usr/local/lib", L"/usr/local/etc"  };  if (Number==0)  {    char *EnvStr=getenv("HOME");    if (EnvStr!=NULL)      GetWideName(EnvStr,NULL,Path,MaxSize);    else      wcsncpyz(Path, ConfPath[0], MaxSize);    return true;  }  Number--;  if (Number>=ASIZE(ConfPath))    return false;  wcsncpyz(Path,ConfPath[Number], MaxSize);  return true;#elif defined(_WIN_ALL)  if (Number>1)    return false;  if (Number==0)    GetRarDataPath(Path,MaxSize,Create);  else  {    GetModuleFileName(NULL,Path,(DWORD)MaxSize);    RemoveNameFromPath(Path);  }  return true;#else  return false;#endif}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:35,


示例3: MakeName

void MakeName(const wchar *Path,const wchar *Name,wchar *Pathname,size_t MaxSize){  // 'Name' and 'Pathname' can point to same memory area. This is why we use  // the temporary buffer instead of constructing the name in 'Pathname'.  wchar OutName[NM];  wcsncpyz(OutName,Path,ASIZE(OutName));  AddEndSlash(OutName,ASIZE(OutName));  wcsncatz(OutName,Name,ASIZE(OutName));  wcsncpyz(Pathname,OutName,MaxSize);}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:10,


示例4: uiAskReplaceEx

// Additionally to handling user input, it analyzes and sets command options.// Returns only 'replace', 'skip' and 'cancel' codes.UIASKREP_RESULT uiAskReplaceEx(RAROptions *Cmd,wchar *Name,size_t MaxNameSize,int64 FileSize,RarTime *FileTime,uint Flags){  if (Cmd->Overwrite==OVERWRITE_NONE)    return UIASKREP_R_SKIP;#if !defined(SFX_MODULE) && !defined(SILENT)  // Must be before Cmd->AllYes check or -y switch would override -or.  if (Cmd->Overwrite==OVERWRITE_AUTORENAME && GetAutoRenamedName(Name,MaxNameSize))    return UIASKREP_R_REPLACE;#endif  // This check must be after OVERWRITE_AUTORENAME processing or -y switch  // would override -or.  if (Cmd->AllYes || Cmd->Overwrite==OVERWRITE_ALL)  {    PrepareToDelete(Name);    return UIASKREP_R_REPLACE;  }  wchar NewName[NM];  wcsncpyz(NewName,Name,ASIZE(NewName));  UIASKREP_RESULT Choice=uiAskReplace(NewName,ASIZE(NewName),FileSize,FileTime,Flags);  if (Choice==UIASKREP_R_REPLACE || Choice==UIASKREP_R_REPLACEALL)    PrepareToDelete(Name);  if (Choice==UIASKREP_R_REPLACEALL)  {    Cmd->Overwrite=OVERWRITE_ALL;    return UIASKREP_R_REPLACE;  }  if (Choice==UIASKREP_R_SKIPALL)  {    Cmd->Overwrite=OVERWRITE_NONE;    return UIASKREP_R_SKIP;  }  if (Choice==UIASKREP_R_RENAME)  {    if (PointToName(NewName)==NewName)      SetName(Name,NewName,MaxNameSize);    else      wcsncpyz(Name,NewName,MaxNameSize);    if (FileExist(Name))      return uiAskReplaceEx(Cmd,Name,MaxNameSize,FileSize,FileTime,Flags);    return UIASKREP_R_REPLACE;  }#if !defined(SFX_MODULE) && !defined(SILENT)  if (Choice==UIASKREP_R_RENAMEAUTO && GetAutoRenamedName(Name,MaxNameSize))  {    Cmd->Overwrite=OVERWRITE_AUTORENAME;    return UIASKREP_R_REPLACE;  }#endif  return Choice;}
开发者ID:1ldk,项目名称:mpc-hc,代码行数:57,


示例5: VolNameToFirstName

// Get the name of first volume. Return the leftmost digit of volume number.wchar* VolNameToFirstName(const wchar *VolName,wchar *FirstName,size_t MaxSize,bool NewNumbering){  if (FirstName!=VolName)    wcsncpyz(FirstName,VolName,MaxSize);  wchar *VolNumStart=FirstName;  if (NewNumbering)  {    wchar N='1';    // From the rightmost digit of volume number to the left.    for (wchar *ChPtr=GetVolNumPart(FirstName);ChPtr>FirstName;ChPtr--)      if (IsDigit(*ChPtr))      {        *ChPtr=N; // Set the rightmost digit to '1' and others to '0'.        N='0';      }      else        if (N=='0')        {          VolNumStart=ChPtr+1; // Store the position of leftmost digit in volume number.          break;        }  }  else  {    // Old volume numbering scheme. Just set the extension to ".rar".    SetExt(FirstName,L"rar",MaxSize);    VolNumStart=GetExt(FirstName);  }  if (!FileExist(FirstName))  {    // If the first volume, which name we just generated, is not exist,    // check if volume with same name and any other extension is available.    // It can help in case of *.exe or *.sfx first volume.    wchar Mask[NM];    wcsncpyz(Mask,FirstName,ASIZE(Mask));    SetExt(Mask,L"*",ASIZE(Mask));    FindFile Find;    Find.SetMask(Mask);    FindData FD;    while (Find.Next(&FD))    {      Archive Arc;      if (Arc.Open(FD.Name,0) && Arc.IsArchive(true) && Arc.FirstVolume)      {        wcsncpyz(FirstName,FD.Name,MaxSize);        break;      }    }  }  return VolNumStart;}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:53,


示例6: ExtractStreams

void ExtractStreams(Archive &Arc,const wchar *FileName,bool TestMode){  wchar FullName[NM+2];  if (FileName[0]!=0 && FileName[1]==0)  {    wcscpy(FullName,L".//");    wcsncpyz(FullName+2,FileName,ASIZE(FullName)-2);  }  else    wcsncpyz(FullName,FileName,ASIZE(FullName));  byte *Data=&Arc.SubHead.SubData[0];  size_t DataSize=Arc.SubHead.SubData.Size();  wchar StreamName[NM];  GetStreamNameNTFS(Arc,StreamName,ASIZE(StreamName));  if (*StreamName!=':')  {    uiMsg(UIERROR_STREAMBROKEN,Arc.FileName,FileName);    ErrHandler.SetErrorCode(RARX_CRC);    return;  }  if (TestMode)  {    Arc.ReadSubData(NULL,NULL);    return;  }  wcsncatz(FullName,StreamName,ASIZE(FullName));  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(FullName) && Arc.ReadSubData(NULL,&CurFile))    CurFile.Close();  File HostFile;  if (Found && HostFile.Open(FileName,FMF_OPENSHARED|FMF_UPDATE))    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,fd.FileAttr);}
开发者ID:Cpasjuste,项目名称:nzbm,代码行数:48,


示例7: WideToChar

bool File::Open(const wchar *Name,uint Mode){  ErrorType=FILE_SUCCESS;  FileHandle hNewFile;  bool OpenShared=File::OpenShared || (Mode & FMF_OPENSHARED)!=0;  bool UpdateMode=(Mode & FMF_UPDATE)!=0;  bool WriteMode=(Mode & FMF_WRITE)!=0;  int flags=UpdateMode ? O_RDWR:(WriteMode ? O_WRONLY:O_RDONLY);  char NameA[NM];  WideToChar(Name,NameA,ASIZE(NameA));  // int handle=open(NameA,flags);  // if (handle==-1)  //   hNewFile=FILE_BAD_HANDLE;  // else  // {  //   hNewFile=fdopen(handle,UpdateMode ? UPDATEBINARY:READBINARY);  // }  hNewFile = jsOpen(Name);  if (hNewFile==FILE_BAD_HANDLE && errno==ENOENT)    ErrorType=FILE_NOTFOUND;  NewFile=false;  HandleType=FILE_HANDLENORMAL;  SkipClose=false;  bool Success=hNewFile!=FILE_BAD_HANDLE;  if (Success)  {    hFile=hNewFile;    wcsncpyz(FileName,Name,ASIZE(FileName));  }  return Success;}
开发者ID:YuJianrong,项目名称:nodejs-unrar,代码行数:32,


示例8: GetAutoRenamedName

bool GetAutoRenamedName(wchar *Name,size_t MaxNameSize){  wchar NewName[NM];  size_t NameLength=wcslen(Name);#ifdef _ANDROID  if (NameLength>ASIZE(NewName)-10)    return false;#endif  wchar *Ext=GetExt(Name);  if (Ext==NULL)    Ext=Name+NameLength;  for (uint FileVer=1;;FileVer++)  {#ifdef _ANDROID // No swprintf in Android NDK r9.    uint NamePrefixLength=Ext-Name;    wcsncpy(NewName,Name,NamePrefixLength);    wcscpy(NewName+NamePrefixLength,L"(");    itoa(FileVer,NewName+NamePrefixLength+1,ASIZE(NewName)-NamePrefixLength-1);    wcsncatz(NewName,L")",ASIZE(NewName));    wcsncatz(NewName,Ext,ASIZE(NewName));#else    swprintf(NewName,ASIZE(NewName),L"%.*ls(%u)%ls",uint(Ext-Name),Name,FileVer,Ext);#endif    if (!FileExist(NewName))    {      wcsncpyz(Name,NewName,MaxNameSize);      break;    }    if (FileVer>=1000000)      return false;  }  return true;}
开发者ID:ccarpo,项目名称:ComicStreamer,代码行数:33,


示例9: wcsncpyz

int CommandData::IsProcessFile(FileHeader &FileHead,bool *ExactMatch,int MatchType,                               wchar *MatchedArg,uint MatchedArgSize){  if (MatchedArg!=NULL && MatchedArgSize>0)    *MatchedArg=0;//  if (wcslen(FileHead.FileName)>=NM)//    return 0;  bool Dir=FileHead.Dir;  if (ExclCheck(FileHead.FileName,Dir,false,true))    return 0;#ifndef SFX_MODULE  if (TimeCheck(FileHead.mtime))    return 0;  if ((FileHead.FileAttr & ExclFileAttr)!=0 || InclAttrSet && (FileHead.FileAttr & InclFileAttr)==0)    return 0;  if (!Dir && SizeCheck(FileHead.UnpSize))    return 0;#endif  wchar *ArgName;  FileArgs.Rewind();  for (int StringCount=1;(ArgName=FileArgs.GetString())!=NULL;StringCount++)    if (CmpName(ArgName,FileHead.FileName,MatchType))    {      if (ExactMatch!=NULL)        *ExactMatch=wcsicompc(ArgName,FileHead.FileName)==0;      if (MatchedArg!=NULL)        wcsncpyz(MatchedArg,ArgName,MatchedArgSize);      return StringCount;    }  return 0;}
开发者ID:abbeycode,项目名称:UnrarKit,代码行数:31,


示例10: while

void CommandData::ReadConfig(){  StringList List;  if (ReadTextFile(DefConfigName,&List,true))  {    wchar *Str;    while ((Str=List.GetString())!=NULL)    {      while (IsSpace(*Str))        Str++;      if (wcsnicomp(Str,L"switches=",9)==0)        ProcessSwitchesString(Str+9);      if (*Command!=0)      {        wchar Cmd[16];        wcsncpyz(Cmd,Command,ASIZE(Cmd));        wchar C0=toupperw(Cmd[0]);        wchar C1=toupperw(Cmd[1]);        if (C0=='I' || C0=='L' || C0=='M' || C0=='S' || C0=='V')          Cmd[1]=0;        if (C0=='R' && (C1=='R' || C1=='V'))          Cmd[2]=0;        wchar SwName[16+ASIZE(Cmd)];        swprintf(SwName,ASIZE(SwName),L"switches_%ls=",Cmd);        size_t Length=wcslen(SwName);        if (wcsnicomp(Str,SwName,Length)==0)          ProcessSwitchesString(Str+Length);      }    }  }}
开发者ID:abbeycode,项目名称:UnrarKit,代码行数:31,


示例11: UnixSlashToDos

bool ScanTree::GetNextMask(){  if (!GetFilteredMask())    return false;#ifdef _WIN_ALL  UnixSlashToDos(CurMask,CurMask,ASIZE(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=IsDriveLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0;  wchar *Name=PointToName(CurMask);  if (*Name==0)    wcsncatz(CurMask,MASKALL,ASIZE(CurMask));  if (Name[0]=='.' && (Name[1]==0 || Name[1]=='.' && Name[2]==0))  {    AddEndSlash(CurMask,ASIZE(CurMask));    wcsncatz(CurMask,MASKALL,ASIZE(CurMask));  }  SpecPathLength=Name-CurMask;  Depth=0;  wcsncpyz(OrigCurMask,CurMask,ASIZE(OrigCurMask));  return true;}
开发者ID:abbeycode,项目名称:UnrarKit,代码行数:28,


示例12: wcsncpyz

void File::operator = (File &SrcFile){  hFile=SrcFile.hFile;  NewFile=SrcFile.NewFile;  LastWrite=SrcFile.LastWrite;  HandleType=SrcFile.HandleType;  wcsncpyz(FileName,SrcFile.FileName,ASIZE(FileName));  SrcFile.SkipClose=true;}
开发者ID:YuJianrong,项目名称:nodejs-unrar,代码行数:9,


示例13: MakeHostFormat

// need thread safe (from WriteLogToFileProc)int MakeHostFormat(LogHost *host, WCHAR *wbuf, int max_len){	int		len = 0;	len += wcsncpyz(wbuf + len, host->nick ? host->nick.s() : host->uid.s(), max_len - len);	len += wcsncpyz(wbuf + len, L" (", max_len - len);	if (host->gname) {		len += wcsncpyz(wbuf + len, host->gname.s(), max_len - len);		len += wcsncpyz(wbuf + len, L"/", max_len - len);	}	len += wcsncpyz(wbuf + len, host->host.s(), max_len - len);	if (host->addr) {		len += wcsncpyz(wbuf + len, L"/", max_len - len);		len += wcsncpyz(wbuf + len, host->addr.s(), max_len - len);	}	len += wcsncpyz(wbuf + len, L"/", max_len - len);	len += wcsncpyz(wbuf + len, host->uid.s(), max_len - len);	len += wcsncpyz(wbuf + len, L")", max_len - len);	return	len;}
开发者ID:shirouzu,项目名称:ipmsg,代码行数:21,


示例14: ConvertNameToFull

void ConvertNameToFull(const wchar *Src,wchar *Dest,size_t MaxSize){  if (Src==NULL || *Src==0)  {    if (MaxSize>0)      *Dest=0;    return;  }#ifdef _WIN_ALL  {    wchar FullName[NM],*NamePtr;    DWORD Code=GetFullPathName(Src,ASIZE(FullName),FullName,&NamePtr);    if (Code==0 || Code>ASIZE(FullName))    {      wchar LongName[NM];      if (GetWinLongPath(Src,LongName,ASIZE(LongName)))        Code=GetFullPathName(LongName,ASIZE(FullName),FullName,&NamePtr);    }    if (Code!=0 && Code<ASIZE(FullName))      wcsncpyz(Dest,FullName,MaxSize);    else      if (Src!=Dest)        wcsncpyz(Dest,Src,MaxSize);  }#elif defined(_UNIX)  if (IsFullPath(Src))    *Dest=0;  else  {    char CurDirA[NM];    if (getcwd(CurDirA,ASIZE(CurDirA))==NULL)      *CurDirA=0;    CharToWide(CurDirA,Dest,MaxSize);    AddEndSlash(Dest,MaxSize);  }  wcsncatz(Dest,Src,MaxSize);#else  wcsncpyz(Dest,Src,MaxSize);#endif}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:40,


示例15: MakeMsgHead

BOOL LogMng::MakeMsgStr(LogMsg *msg, Wstr *wbuf, CopyMsgFlags flags){#define MAX_HEAD_BUF	8192	int		max_len = (msg->body.Len() + 5) * 2 + MAX_HEAD_BUF;	int		len = 0;	wbuf->Init(max_len);	if (flags & HEADMSG_COPY) {		len += MakeMsgHead(msg, wbuf->Buf(), max_len, (flags & SELFHEAD_COPY));	}	len += UnixNewLineToLocalW(msg->body.s(), wbuf->Buf() + len, max_len - len);	len += wcsncpyz(wbuf->Buf() + len, L"/r/n/r/n", max_len - len);	return	TRUE;}
开发者ID:shirouzu,项目名称:ipmsg,代码行数:15,


示例16: FindClose

bool FindFile::FastFind(const wchar *FindMask,FindData *fd,bool GetSymLink){  fd->Error=false;#ifndef _UNIX  if (IsWildcard(FindMask))    return false;#endif    #ifdef _WIN_ALL  HANDLE hFind=Win32Find(INVALID_HANDLE_VALUE,FindMask,fd);  if (hFind==INVALID_HANDLE_VALUE)    return false;  FindClose(hFind);#else  char FindMaskA[NM];  WideToChar(FindMask,FindMaskA,ASIZE(FindMaskA));  struct stat st;  if (GetSymLink)  {#ifdef SAVE_LINKS    if (lstat(FindMaskA,&st)!=0)#else    if (stat(FindMaskA,&st)!=0)#endif    {      fd->Error=(errno!=ENOENT);      return false;    }  }  else    if (stat(FindMaskA,&st)!=0)    {      fd->Error=(errno!=ENOENT);      return false;    }  fd->FileAttr=st.st_mode;  fd->Size=st.st_size;  fd->mtime=st.st_mtime;  fd->atime=st.st_atime;  fd->ctime=st.st_ctime;  wcsncpyz(fd->Name,FindMask,ASIZE(fd->Name));#endif  fd->Flags=0;  fd->IsDir=IsDir(fd->FileAttr);  fd->IsLink=IsLink(fd->FileAttr);  return true;}
开发者ID:717717,项目名称:sumatrapdf,代码行数:48,


示例17: uiMsg

bool CmdExtract::ExtrCreateFile(Archive &Arc,File &CurFile){  return true;	// OPENMPT ADDITION  bool Success=true;  wchar Command=Cmd->Command[0];#if !defined(GUI) && !defined(SFX_MODULE)  if (Command=='P')    CurFile.SetHandleType(FILE_HANDLESTD);#endif  if ((Command=='E' || Command=='X') && !Cmd->Test)  {    bool UserReject;    // Specify "write only" mode to avoid OpenIndiana NAS problems    // with SetFileTime and read+write files.    if (!FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))    {      Success=false;      if (!UserReject)      {        ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);#ifdef RARDLL        Cmd->DllError=ERAR_ECREATE;#endif        if (!IsNameUsable(DestFileName))        {          uiMsg(UIMSG_CORRECTINGNAME,Arc.FileName);          wchar OrigName[ASIZE(DestFileName)];          wcsncpyz(OrigName,DestFileName,ASIZE(OrigName));          MakeNameUsable(DestFileName,true);          CreatePath(DestFileName,true);          if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))          {#ifndef SFX_MODULE            uiMsg(UIERROR_RENAMING,Arc.FileName,OrigName,DestFileName);#endif            Success=true;          }          else            ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);        }      }    }  }  return Success;}
开发者ID:ksnydertn,项目名称:modplug,代码行数:48,


示例18: Ask

int Ask(const wchar *AskStr){  Alarm();  const int MaxItems=10;  wchar Item[MaxItems][40];  int ItemKeyPos[MaxItems],NumItems=0;  for (const wchar *NextItem=AskStr;NextItem!=NULL;NextItem=wcschr(NextItem+1,'_'))  {    wchar *CurItem=Item[NumItems];    wcsncpyz(CurItem,NextItem+1,ASIZE(Item[0]));    wchar *EndItem=wcschr(CurItem,'_');    if (EndItem!=NULL)      *EndItem=0;    int KeyPos=0,CurKey;    while ((CurKey=CurItem[KeyPos])!=0)    {      bool Found=false;      for (int I=0;I<NumItems && !Found;I++)        if (toupperw(Item[I][ItemKeyPos[I]])==toupperw(CurKey))          Found=true;      if (!Found && CurKey!=' ')        break;      KeyPos++;    }    ItemKeyPos[NumItems]=KeyPos;    NumItems++;  }  for (int I=0;I<NumItems;I++)  {    eprintf(I==0 ? (NumItems>4 ? L"/n":L" "):L", ");    int KeyPos=ItemKeyPos[I];    for (int J=0;J<KeyPos;J++)      eprintf(L"%c",Item[I][J]);    eprintf(L"[%c]%ls",Item[I][KeyPos],&Item[I][KeyPos+1]);  }  eprintf(L" ");  wchar Str[50];  getwstr(Str,ASIZE(Str));  wchar Ch=toupperw(Str[0]);  for (int I=0;I<NumItems;I++)    if (Ch==Item[I][ItemKeyPos[I]])      return I+1;  return 0;}
开发者ID:BSzili,项目名称:aros-stuff,代码行数:47,


示例19: Log

bool CmdExtract::ExtrCreateFile(CommandData *Cmd,Archive &Arc,File &CurFile){  bool Success=true;  wchar Command=Cmd->Command[0];#if !defined(GUI) && !defined(SFX_MODULE)  if (Command=='P')    CurFile.SetHandleType(FILE_HANDLESTD);#endif  if ((Command=='E' || Command=='X') && !Cmd->Test)  {    bool UserReject;    // Specify "write only" mode to avoid OpenIndiana NAS problems    // with SetFileTime and read+write files.    if (!FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),Cmd->Overwrite,&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))    {      Success=false;      if (!UserReject)      {        ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);        ErrHandler.SetErrorCode(RARX_CREATE);#ifdef RARDLL        Cmd->DllError=ERAR_ECREATE;#endif        if (!IsNameUsable(DestFileName))        {          Log(Arc.FileName,St(MCorrectingName));          wchar OrigName[ASIZE(DestFileName)];          wcsncpyz(OrigName,DestFileName,ASIZE(OrigName));          MakeNameUsable(DestFileName,true);          CreatePath(DestFileName,true);          if (FileCreate(Cmd,&CurFile,DestFileName,ASIZE(DestFileName),Cmd->Overwrite,&UserReject,Arc.FileHead.UnpSize,&Arc.FileHead.mtime,true))          {#ifndef SFX_MODULE            Log(Arc.FileName,St(MRenaming),OrigName,DestFileName);#endif            Success=true;          }          else            ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName);        }      }    }  }  return Success;}
开发者ID:ikvm,项目名称:mpc-hc,代码行数:47,


示例20: wcsncpyz

// For masks like dir1/dir2*/*.ext in non-recursive mode.bool ScanTree::ExpandFolderMask(){  bool WildcardFound=false;  uint SlashPos=0;  for (int I=0;CurMask[I]!=0;I++)  {    if (CurMask[I]=='?' || CurMask[I]=='*')      WildcardFound=true;    if (WildcardFound && IsPathDiv(CurMask[I]))    {      // First path separator position after folder wildcard mask.      // In case of dir1/dir2*/dir3/name.ext mask it may point not to file      // name, so we cannot use PointToName() here.      SlashPos=I;       break;    }  }  wchar Mask[NM];  wcsncpyz(Mask,CurMask,ASIZE(Mask));  Mask[SlashPos]=0;  // Prepare the list of all folders matching the wildcard mask.  ExpandedFolderList.Reset();  FindFile Find;  Find.SetMask(Mask);  FindData FD;  while (Find.Next(&FD))    if (FD.IsDir)    {      wcsncatz(FD.Name,CurMask+SlashPos,ASIZE(FD.Name));      // Treat dir*/* or dir*/*.* as dir, so empty 'dir' is also matched      // by such mask. Skipping empty dir with dir*/*.* confused some users.      wchar *LastMask=PointToName(FD.Name);      if (wcscmp(LastMask,L"*")==0 || wcscmp(LastMask,L"*.*")==0)        RemoveNameFromPath(FD.Name);      ExpandedFolderList.AddString(FD.Name);    }  if (ExpandedFolderList.ItemsCount()==0)    return false;  // Return the first matching folder name now.  ExpandedFolderList.GetString(CurMask,ASIZE(CurMask));  return true;}
开发者ID:abbeycode,项目名称:UnrarKit,代码行数:47,


示例21: ConvertPath

wchar* ConvertPath(const wchar *SrcPath,wchar *DestPath){  const wchar *DestPtr=SrcPath;  // Prevent /../ in any part of path string.  for (const wchar *s=DestPtr;*s!=0;s++)    if (IsPathDiv(s[0]) && s[1]=='.' && s[2]=='.' && IsPathDiv(s[3]))      DestPtr=s+4;  // Remove <d>:/ and any sequence of . and / in the beginning of path string.  while (*DestPtr!=0)  {    const wchar *s=DestPtr;    if (s[0] && IsDriveDiv(s[1]))      s+=2;    if (s[0]=='//' && s[1]=='//')    {      const wchar *Slash=wcschr(s+2,'//');      if (Slash!=NULL && (Slash=wcschr(Slash+1,'//'))!=NULL)        s=Slash+1;    }    for (const wchar *t=s;*t!=0;t++)      if (IsPathDiv(*t))        s=t+1;      else        if (*t!='.')          break;    if (s==DestPtr)      break;    DestPtr=s;  }  // Code above does not remove last "..", doing here.  if (DestPtr[0]=='.' && DestPtr[1]=='.' && DestPtr[2]==0)    DestPtr+=2;    if (DestPath!=NULL)  {    // SrcPath and DestPath can point to same memory area,    // so we use the temporary buffer for copying.    wchar TmpStr[NM];    wcsncpyz(TmpStr,DestPtr,ASIZE(TmpStr));    wcscpy(DestPath,TmpStr);  }  return (wchar *)DestPtr;}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:46,


示例22: wcsncpyz

HANDLE FindFile::Win32Find(HANDLE hFind,const wchar *Mask,FindData *fd){  WIN32_FIND_DATAW FindData;  if (hFind==INVALID_HANDLE_VALUE)  {    hFind=FindFirstFile(Mask,&FindData);    if (hFind==INVALID_HANDLE_VALUE)    {      wchar LongMask[NM];      if (GetWinLongPath(Mask,LongMask,ASIZE(LongMask)))        hFind=FindFirstFile(LongMask,&FindData);    }    if (hFind==INVALID_HANDLE_VALUE)    {      int SysErr=GetLastError();      fd->Error=(SysErr!=ERROR_FILE_NOT_FOUND &&                 SysErr!=ERROR_PATH_NOT_FOUND &&                 SysErr!=ERROR_NO_MORE_FILES);    }  }  else    if (!FindNextFile(hFind,&FindData))    {      hFind=INVALID_HANDLE_VALUE;      fd->Error=GetLastError()!=ERROR_NO_MORE_FILES;    }  if (hFind!=INVALID_HANDLE_VALUE)  {    wcsncpyz(fd->Name,Mask,ASIZE(fd->Name));    SetName(fd->Name,FindData.cFileName,ASIZE(fd->Name));    fd->Size=INT32TO64(FindData.nFileSizeHigh,FindData.nFileSizeLow);    fd->FileAttr=FindData.dwFileAttributes;    fd->ftCreationTime=FindData.ftCreationTime;    fd->ftLastAccessTime=FindData.ftLastAccessTime;    fd->ftLastWriteTime=FindData.ftLastWriteTime;    fd->mtime=FindData.ftLastWriteTime;    fd->ctime=FindData.ftCreationTime;    fd->atime=FindData.ftLastAccessTime;  }  fd->Flags=0;  return hFind;}
开发者ID:717717,项目名称:sumatrapdf,代码行数:45,


示例23: MakePathW

/*=========================================================================	パス合成(UNICODE 版)=========================================================================*/int MakePathW(WCHAR *dest, const WCHAR *dir, const WCHAR *file, int max_len){	if (!dir) {		dir = dest;	}	int	len;	if (dest == dir) {		len = (int)wcslen(dir);	} else {		len = wcscpyz(dest, dir);	}	if (len > 0 && dest[len -1] != '//') {		dest[len++] = '//';	}	return	len + wcsncpyz(dest + len, file, max_len - len);}
开发者ID:Mapaler,项目名称:FastCopy-M,代码行数:21,


示例24: mprintf

void CmdExtract::ExtrCreateDir(Archive &Arc,const wchar *ArcFileName){  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)      {        wchar OrigName[ASIZE(DestFileName)];        wcsncpyz(OrigName,DestFileName,ASIZE(OrigName));        MakeNameUsable(DestFileName,true);        CreatePath(DestFileName,true);        MDCode=MakeDir(DestFileName,!Cmd->IgnoreGeneralAttr,Arc.FileHead.FileAttr);#ifndef SFX_MODULE        if (MDCode==MKDIR_SUCCESS)          uiMsg(UIERROR_RENAMING,Arc.FileName,OrigName,DestFileName);#endif      }    }  }  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:KastB,项目名称:OpenCPN,代码行数:79,


示例25: wcsncpyz

void CmdExtract::ExtrPrepareName(Archive &Arc,const wchar *ArcFileName,wchar *DestName,size_t DestSize){  wcsncpyz(DestName,Cmd->ExtrPath,DestSize);  // We need IsPathDiv check here to correctly handle Unix forward slash  // in the end of destination path in Windows: rar x arc dest/  if (*Cmd->ExtrPath!=0 && !IsPathDiv(*PointToLastChar(Cmd->ExtrPath)))  {    // Destination path can be without trailing slash if it come from GUI shell.    AddEndSlash(DestName,DestSize);  }#ifndef SFX_MODULE  if (Cmd->AppendArcNameToPath)  {    wcsncatz(DestName,PointToName(Arc.FirstVolumeName),DestSize);    SetExt(DestName,NULL,DestSize);    AddEndSlash(DestName,DestSize);  }#endif#ifndef SFX_MODULE  size_t ArcPathLength=wcslen(Cmd->ArcPath);  if (ArcPathLength>0)  {    size_t NameLength=wcslen(ArcFileName);    ArcFileName+=Min(ArcPathLength,NameLength);    while (*ArcFileName==CPATHDIVIDER)      ArcFileName++;    if (*ArcFileName==0) // Excessive -ap switch.    {      *DestName=0;      return;    }  }#endif  wchar Command=Cmd->Command[0];  // Use -ep3 only in systems, where disk letters are exist, not in Unix.  bool AbsPaths=Cmd->ExclPath==EXCL_ABSPATH && Command=='X' && IsDriveDiv(':');  // We do not use any user specified destination paths when extracting  // absolute paths in -ep3 mode.  if (AbsPaths)    *DestName=0;  if (Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH)    wcsncatz(DestName,PointToName(ArcFileName),DestSize);  else    wcsncatz(DestName,ArcFileName,DestSize);  wchar DiskLetter=toupperw(DestName[0]);  if (AbsPaths)  {    if (DestName[1]=='_' && IsPathDiv(DestName[2]) &&        DiskLetter>='A' && DiskLetter<='Z')      DestName[1]=':';    else      if (DestName[0]=='_' && DestName[1]=='_')      {        // Convert __server/share to //server/share.        DestName[0]=CPATHDIVIDER;        DestName[1]=CPATHDIVIDER;      }  }}
开发者ID:KastB,项目名称:OpenCPN,代码行数:67,


示例26: SetExtraInfo20

bool 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      // Supposing we unpack an old RAR volume without end of archive record      // and last file is not split between volumes.      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;  wchar MatchedArg[NM];  int MatchNumber=Cmd->IsProcessFile(Arc.FileHead,&EqualNames,MatchType,MatchedArg,ASIZE(MatchedArg));  bool MatchFound=MatchNumber!=0;#ifndef SFX_MODULE  if (Cmd->ExclPath==EXCL_BASEPATH)  {    wcsncpyz(Cmd->ArcPath,MatchedArg,ASIZE(Cmd->ArcPath));    *PointToName(Cmd->ArcPath)=0;    if (IsWildcard(Cmd->ArcPath)) // Cannot correctly process path*/* masks here.      *Cmd->ArcPath=0;  }#endif  if (MatchFound && !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;      }    }//.........这里部分代码省略.........
开发者ID:KastB,项目名称:OpenCPN,代码行数:101,


示例27: ProcessFile

int PASCAL ProcessFile(HANDLE hArcData,int Operation,char *DestPath,char *DestName,wchar *DestPathW,wchar *DestNameW){  DataSet *Data=(DataSet *)hArcData;  try  {    Data->Cmd.DllError=0;    if (Data->OpenMode==RAR_OM_LIST || Data->OpenMode==RAR_OM_LIST_INCSPLIT ||        Operation==RAR_SKIP && !Data->Arc.Solid)    {      if (Data->Arc.Volume && Data->Arc.GetHeaderType()==HEAD_FILE &&          Data->Arc.FileHead.SplitAfter)        if (MergeArchive(Data->Arc,NULL,false,'L'))        {          Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);          return ERAR_SUCCESS;        }        else          return ERAR_EOPEN;      Data->Arc.SeekToNext();    }    else    {      Data->Cmd.DllOpMode=Operation;      *Data->Cmd.ExtrPath=0;      *Data->Cmd.DllDestName=0;      if (DestPath!=NULL)      {        char ExtrPathA[NM];        strncpyz(ExtrPathA,DestPath,ASIZE(ExtrPathA)-2);#ifdef _WIN_ALL        // We must not apply OemToCharBuffA directly to DestPath,        // because we do not know DestPath length and OemToCharBuffA        // does not stop at 0.        OemToCharA(ExtrPathA,ExtrPathA);#endif        CharToWide(ExtrPathA,Data->Cmd.ExtrPath,ASIZE(Data->Cmd.ExtrPath));        AddEndSlash(Data->Cmd.ExtrPath,ASIZE(Data->Cmd.ExtrPath));      }      if (DestName!=NULL)      {        char DestNameA[NM];        strncpyz(DestNameA,DestName,ASIZE(DestNameA)-2);#ifdef _WIN_ALL        // We must not apply OemToCharBuffA directly to DestName,        // because we do not know DestName length and OemToCharBuffA        // does not stop at 0.        OemToCharA(DestNameA,DestNameA);#endif        CharToWide(DestNameA,Data->Cmd.DllDestName,ASIZE(Data->Cmd.DllDestName));      }      if (DestPathW!=NULL)      {        wcsncpy(Data->Cmd.ExtrPath,DestPathW,ASIZE(Data->Cmd.ExtrPath));        AddEndSlash(Data->Cmd.ExtrPath,ASIZE(Data->Cmd.ExtrPath));      }      if (DestNameW!=NULL)        wcsncpyz(Data->Cmd.DllDestName,DestNameW,ASIZE(Data->Cmd.DllDestName));      wcscpy(Data->Cmd.Command,Operation==RAR_EXTRACT ? L"X":L"T");      Data->Cmd.Test=Operation!=RAR_EXTRACT;      bool Repeat=false;      Data->Extract.ExtractCurrentFile(Data->Arc,Data->HeaderSize,Repeat);      // Now we process extra file information if any.      //      // Archive can be closed if we process volumes, next volume is missing      // and current one is already removed or deleted. So we need to check      // if archive is still open to avoid calling file operations on      // the invalid file handle. Some of our file operations like Seek()      // process such invalid handle correctly, some not.      while (Data->Arc.IsOpened() && Data->Arc.ReadHeader()!=0 &&              Data->Arc.GetHeaderType()==HEAD_SERVICE)      {        Data->Extract.ExtractCurrentFile(Data->Arc,Data->HeaderSize,Repeat);        Data->Arc.SeekToNext();      }      Data->Arc.Seek(Data->Arc.CurBlockPos,SEEK_SET);    }  }  catch (std::bad_alloc&)  {    return ERAR_NO_MEMORY;  }  catch (RAR_EXIT ErrCode)  {    return Data->Cmd.DllError!=0 ? Data->Cmd.DllError : RarErrorToDll(ErrCode);  }  return Data->Cmd.DllError;}
开发者ID:1ldk,项目名称:mpc-hc,代码行数:93,


示例28: ExpandFolderMask

// For masks like dir1/dir2*/file.ext this function sets 'dir1' recursive mask// and '*/dir2*/file.ext' filter. Masks without folder wildcards are// returned as is.bool ScanTree::GetFilteredMask(){  // If we have some matching folders left for non-recursive folder wildcard  // mask, we return it here.  if (ExpandedFolderList.ItemsCount()>0 && ExpandedFolderList.GetString(CurMask,ASIZE(CurMask)))    return true;  FolderWildcards=false;  FilterList.Reset();  if (!FileMasks->GetString(CurMask,ASIZE(CurMask)))    return false;  // Check if folder wildcards present.  bool WildcardFound=false;  uint FolderWildcardCount=0;  uint SlashPos=0;  uint StartPos=0;#ifdef _WIN_ALL // Not treat the special NTFS //?/d: path prefix as a wildcard.  if (CurMask[0]=='//' && CurMask[1]=='//' && CurMask[2]=='?' && CurMask[3]=='//')    StartPos=4;#endif  for (uint I=StartPos;CurMask[I]!=0;I++)  {    if (CurMask[I]=='?' || CurMask[I]=='*')      WildcardFound=true;    if (IsPathDiv(CurMask[I]) || IsDriveDiv(CurMask[I]))    {      if (WildcardFound)      {        // Calculate a number of folder wildcards in current mask.        FolderWildcardCount++;        WildcardFound=false;      }      if (FolderWildcardCount==0)        SlashPos=I; // Slash position before first folder wildcard mask.    }  }  if (FolderWildcardCount==0)    return true;  FolderWildcards=true; // Global folder wildcards flag.  // If we have only one folder wildcard component and -r is missing or -r-  // is specified, prepare matching folders in non-recursive mode.  // We assume -r for masks like dir1*/dir2*/file*, because it is complicated  // to fast find them using OS file find API call.  if ((Recurse==RECURSE_NONE || Recurse==RECURSE_DISABLE) && FolderWildcardCount==1)    return ExpandFolderMask();  wchar Filter[NM];  // Convert path/dir*/ to */dir filter to search for 'dir' in all 'path' subfolders.  wcsncpyz(Filter,L"*",ASIZE(Filter));  AddEndSlash(Filter,ASIZE(Filter));  // SlashPos might point or not point to path separator for masks like 'dir*', '/dir*' or 'd:dir*'  wchar *WildName=IsPathDiv(CurMask[SlashPos]) || IsDriveDiv(CurMask[SlashPos]) ? CurMask+SlashPos+1 : CurMask+SlashPos;  wcsncatz(Filter,WildName,ASIZE(Filter));  // Treat dir*/* or dir*/*.* as dir/, so empty 'dir' is also matched  // by such mask. Skipping empty dir with dir*/*.* confused some users.  wchar *LastMask=PointToName(Filter);  if (wcscmp(LastMask,L"*")==0 || wcscmp(LastMask,L"*.*")==0)    *LastMask=0;  FilterList.AddString(Filter);  bool RelativeDrive=IsDriveDiv(CurMask[SlashPos]);  if (RelativeDrive)    SlashPos++; // Use "d:" instead of "d" for d:* mask.  CurMask[SlashPos]=0;  if (!RelativeDrive) // Keep d: mask as is, not convert to d:/*  {    // We need to append "/*" both for -ep1 to work correctly and to    // convert d:/* masks previously truncated to d: back to original form.    AddEndSlash(CurMask,ASIZE(CurMask));    wcsncatz(CurMask,MASKALL,ASIZE(CurMask));  }  return true;}
开发者ID:sina-ht,项目名称:enfle,代码行数:82,



注:本文中的wcsncpyz函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ wcspbrk函数代码示例
C++ wcsncmp函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。