// 连接提示 bool CLogic::LinkPrompt(BYTE chess[CHESSCOUNT_H][CHESSCOUNT_W], CPoint * first, CPoint * end) { CPoint t1,t2; CArrayTemplate<CPoint> v; for(int i=0; i<CHESSCOUNT_H; i++) { for(int j=0; j<CHESSCOUNT_W; j++) { for(int _i=0; _i<CHESSCOUNT_H; _i++) { for(int _j=0; _j<CHESSCOUNT_W; _j++) { if(i!=_i || j!=_j) { v.RemoveAll(); if(chess[i][j]!= ERROR_ALL && chess[i][j] == chess[_i][_j] && IsLink(chess,CPoint(j,i),CPoint(_j,_i),&v,&t1,&t2)) { first->x = j; first->y = i; end->x = _j; end->y = _i; return true; } } } } } } return false; }
int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,unsigned int &LinkCRC,bool Create) { #if defined(SAVE_LINKS) && defined(_UNIX) char FileName[NM]; if (IsLink(Arc.NewLhd.FileAttr)) { int DataSize=Min(Arc.NewLhd.PackSize,sizeof(FileName)-1); DataIO.UnpRead((unsigned char *)FileName,DataSize); FileName[DataSize]=0; if (Create) { CreatePath(DestName,NULL,true); if (symlink(FileName,DestName)==-1) if (errno==EEXIST) Log(Arc.FileName,St(MSymLinkExists),DestName); else { Log(Arc.FileName,St(MErrCreateLnk),DestName); ErrHandler.SetErrorCode(WARNING); } } LinkCRC=CRC(0xffffffff,FileName,DataSize); return(1); } #endif return(0); }
bool CGameLogic::SearchValidPath(int anMap[MAX_ROW][MAX_COL]) { int nInfo1, nInfo2; Vertex v1, v2; for(int i = 0 ; i < m_nSetRow ; i++) { for(int j = 0 ; j < m_nSetCol ; j++) { if(anMap[i][j]!=BLANK) { nInfo1 = anMap[i][j]; v1.row = i ; v1.col = j ; for(int m = 0 ; m < m_nSetRow ; m++) { for(int n = 0 ; n < m_nSetCol ; n++) { if(anMap[i][j]!=BLANK && (i!=m || j!=n) && nInfo1 == anMap[m][n]) { nInfo2 = anMap[m][n]; v2.row = m ; v2.col = n ; if(IsLink(anMap,v1,v2)) return true; } } } } } } return false; }
bool ExtractLink(ComprDataIO &DataIO,Archive &Arc,const char *LinkName,uint &LinkCRC,bool Create) { #if defined(SAVE_LINKS) && defined(_UNIX) char LinkTarget[NM]; if (IsLink(Arc.NewLhd.FileAttr)) { int DataSize=Min(Arc.NewLhd.PackSize,sizeof(LinkTarget)-1); DataIO.UnpRead((byte *)LinkTarget,DataSize); LinkTarget[DataSize]=0; if (Create) { CreatePath(LinkName,NULL,true); if (symlink(LinkTarget,LinkName)==-1) // Error. if (errno==EEXIST) Log(Arc.FileName,St(MSymLinkExists),LinkName); else { Log(Arc.FileName,St(MErrCreateLnk),LinkName); ErrHandler.SetErrorCode(RARX_WARNING); } // We do not set time of created symlink, because utime changes // time of link target and lutimes is not available on all Linux // systems at the moment of writing this code. } int NameSize=Min(DataSize,strlen(LinkTarget)); LinkCRC=CRC(0xffffffff,LinkTarget,NameSize); return(true); } #endif return(false); }
wxString wxFileData::GetHint() const { wxString s = m_filePath; s += wxT(" "); if (IsDir()) s += _("<DIR>"); else if (IsLink()) s += _("<LINK>"); else if (IsDrive()) s += _("<DRIVE>"); else // plain file s += wxString::Format( _("%ld bytes"), m_size ); s += wxT(' '); if ( !IsDrive() ) { s << GetModificationTime() << wxT(" ") << m_permissions; } return s; };
wxString wxFileData::GetEntry( fileListFieldType num ) const { wxString s; switch ( num ) { case FileList_Name: s = m_fileName; break; case FileList_Size: if (!IsDir() && !IsLink() && !IsDrive()) s.Printf(_T("%ld"), m_size); break; case FileList_Type: s = GetFileType(); break; case FileList_Time: if (!IsDrive()) s = GetModificationTime(); break; #if defined(__UNIX__) || defined(__WIN32__) case FileList_Perm: s = m_permissions; break; #endif // defined(__UNIX__) || defined(__WIN32__) default: wxFAIL_MSG( _T("unexpected field in wxFileData::GetEntry()") ); } return s; }
int ExtractLink(ComprDataIO &DataIO,Archive &Arc,char *DestName,uint &LinkCRC,bool Create) { #if defined(SAVE_LINKS) && defined(_UNIX) char FileName[NM]; if (IsLink(Arc.NewLhd.FileAttr)) { uint DataSize=Min(Arc.NewLhd.PackSize,sizeof(FileName)-1); DataIO.UnpRead((byte *)FileName,DataSize); FileName[DataSize]=0; if (Create) { CStdString strPath = URIUtils::GetDirectory(DestName); CUtil::CreateDirectoryEx(strPath); if (symlink(FileName,DestName)==-1) { if (errno==EEXIST) Log(Arc.FileName,St(MSymLinkExists),DestName); else { Log(Arc.FileName,St(MErrCreateLnk),DestName); ErrHandler.SetErrorCode(WARNING); } } } int NameSize=Min(DataSize,strlen(FileName)); LinkCRC=CRC(0xffffffff,FileName,NameSize); return(1); } #endif return(0); }
void CHTMLImageSection::OnDraw( GS::CDrawContext &dc ) { if( m_pImage ) { if( m_nBorder ) { COLORREF clr = RGB( 0, 0, 0 ); // // Top border WinHelper::CRect rc( left, top, right, top + m_nBorder ); dc.FillRect( rc, clr ); // // Bottom border rc.bottom = bottom; rc.top = bottom - m_nBorder; dc.FillRect( rc, clr ); // // Left border rc.top = top; rc.right = rc.left + m_nBorder; dc.FillRect( rc, clr ); // // Right border rc.right = right; rc.left = right - m_nBorder; dc.FillRect( rc, clr ); (void)m_pImage->StretchFrame( m_nFrame, dc.GetSafeHdc(), left + m_nBorder, top + m_nBorder, right - m_nBorder, bottom - m_nBorder ); } else { (void)m_pImage->StretchFrame( m_nFrame, dc.GetSafeHdc(), left, top, right, bottom ); } } else { static TCHAR sz[] = _T("Image missing"); dc.SelectFont( g_defaults.m_strFontName, GetFontSizeAsPixels( dc.GetSafeHdc(), g_defaults.m_nFontSize, 0 ), FW_NORMAL, false, false, false, g_defaults.m_cCharSet ); dc.DrawText( left, top, sz, countof( sz ) - 1, 0 ); dc.Rectangle( *this, CHTMLSectionABC::LinkHoverColour() ); } if( IsMouseInSection() && IsLink() ) { dc.Rectangle( *this, CHTMLSectionABC::LinkHoverColour() ); } #ifdef DRAW_DEBUG // Do this after the image so it draws on top! CHTMLSectionABC::OnDraw( dc ); #endif // DRAW_DEBUG }
/* ShowDirectory - traverses a file directory and outputs accordingly * returns: size of ALL elements inside directory */ int ShowDirectory(char *param, int aFlag,int lFlag) { struct dirent* entry; struct stat statbuf; DIR* dir; char fullpath[1024]; char chrdir[1024]; int size = 0; int dirSize = 0; if ((dir = opendir(param)) == NULL) { perror("Failed to open directory"); return 1; } while ((entry = readdir(dir))) { // iterate through each element in directory strcpy(chrdir, ""); strcat(chrdir, param); // construct full path to read element strcat(chrdir, "/"); strcat(chrdir, entry->d_name); if ((strcmp(entry->d_name, "..") == 0) || (strcmp(entry->d_name, ".") == 0)) { continue; } if (IsDirectory(chrdir)) { dirSize = ShowDirectory(chrdir, aFlag, lFlag); // element is a directory, goto next level first stat(chrdir, &statbuf); dirSize += (int)statbuf.st_size; // add size of cwd link to total printf("%-10d", dirSize); printf("\t%s\n", chrdir); size += dirSize; // must add size of this dir to running total } else if (IsFile(chrdir)) { if (IsLink(chrdir) && !lFlag) { // handles the -L option lstat(chrdir, &statbuf); } else { stat(chrdir, &statbuf); } size += (int)statbuf.st_size; if (aFlag) { // handles the -a option printf("%-10d",(int)statbuf.st_size); printf("\t%s\n", chrdir); } } } closedir(dir); return size; }
void CCLLKDlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 int x=(point.x-m_iSeekX)/FRONTWIDTH+((point.x-m_iSeekX)%FRONTWIDTH?1:0); int y=(point.y-m_iSeekY)/FRONTHEIGHT+((point.y-m_iSeekY)%FRONTHEIGHT?1:0); if(x>0&&y>0&&x<m_nCol&&y<m_nRow) { if((x!=m_nX1||y!=m_nY1)) { if (x<m_nCol&&y<m_nRow&&m_map[y*m_nCol+x]!=BLANK_STATE) { if (!IsSelected) { IsSelected=!IsSelected; m_nX1=x; m_nY1=y; } else//Selected { if (m_map[m_nY1*m_nCol+m_nX1]==m_map[y*m_nCol+x]) { if (IsLink(m_nX1,m_nY1,x,y)) { DrawLink(m_nX1,m_nY1,x,y); m_map[m_nY1*m_nCol+m_nX1]=BLANK_STATE; m_map[y*m_nCol+x]=BLANK_STATE; IsSelected=!IsSelected; } else { m_nY1=y; m_nX1=x; } } else { m_nY1=y; m_nX1=x; } } if (IsWin()) { Invalidate(false); MessageBox("胜利闯关,即将开始新局!","恭喜您",MB_OK|MB_ICONWARNING); StartNewGame(); } } } } Invalidate(FALSE); //CDialog::OnLButtonDown(nFlags, point); }
wxString wxFileData::GetFileType() const { if (IsDir()) return _("<DIR>"); else if (IsLink()) return _("<LINK>"); else if (IsDrive()) return _("<DRIVE>"); else if (m_fileName.Find(wxT('.'), true) != wxNOT_FOUND) return m_fileName.AfterLast(wxT('.')); return wxEmptyString; }
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; }
bool SVGAElement::IsFocusableInternal(int32_t *aTabIndex, bool aWithMouse) { nsCOMPtr<nsIURI> uri; if (IsLink(getter_AddRefs(uri))) { if (aTabIndex) { *aTabIndex = ((sTabFocusModel & eTabFocus_linksMask) == 0 ? -1 : 0); } return true; } if (aTabIndex) { *aTabIndex = -1; } return false; }
PRBool nsXMLElement::IsFocusable(PRInt32 *aTabIndex) { nsCOMPtr<nsIURI> absURI; if (IsLink(getter_AddRefs(absURI))) { if (aTabIndex) { *aTabIndex = ((sTabFocusModel & eTabFocus_linksMask) == 0 ? -1 : 0); } return PR_TRUE; } if (aTabIndex) { *aTabIndex = -1; } return PR_FALSE; }
bool nsSVGAElement::IsFocusable(PRInt32 *aTabIndex, bool aWithMouse) { nsCOMPtr<nsIURI> uri; if (IsLink(getter_AddRefs(uri))) { if (aTabIndex) { *aTabIndex = ((sTabFocusModel & eTabFocus_linksMask) == 0 ? -1 : 0); } return PR_TRUE; } if (aTabIndex) { *aTabIndex = -1; } return PR_FALSE; }
void wxFileData::MakeItem( wxListItem &item ) { item.m_text = m_fileName; item.ClearAttributes(); if (IsExe()) item.SetTextColour(*wxRED); if (IsDir()) item.SetTextColour(*wxBLUE); item.m_image = m_image; if (IsLink()) { wxColour dg = wxTheColourDatabase->Find( _T("MEDIUM GREY") ); if ( dg.Ok() ) item.SetTextColour(dg); } item.m_data = (long)this; }
bool ExtractUnixLink30(ComprDataIO &DataIO,Archive &Arc,const wchar *LinkName) { char Target[NM]; if (IsLink(Arc.FileHead.FileAttr)) { size_t DataSize=Min(Arc.FileHead.PackSize,ASIZE(Target)-1); DataIO.UnpRead((byte *)Target,DataSize); Target[DataSize]=0; DataIO.UnpHash.Init(Arc.FileHead.FileHash.Type,1); DataIO.UnpHash.Update(Target,strlen(Target)); DataIO.UnpHash.Result(&Arc.FileHead.FileHash); // Return true in case of bad checksum, so link will be processed further // and extraction routine will report the checksum error. if (!DataIO.UnpHash.Cmp(&Arc.FileHead.FileHash,Arc.FileHead.UseHashKey ? Arc.FileHead.HashKey:NULL)) return true; return UnixSymlink(Target,LinkName); } return false; }
void CopyFile(const std::string &src, std::string dest, TFileOpCB cb, void *prvdata) { MakeOptDest(src, dest); if (src == dest) return; if (IsLink(src)) { if (FileExists(dest) && !IsDir(dest)) Unlink(dest.c_str()); SymLink(src, dest); return; } CFDWrapper in(Open(src.c_str(), O_RDONLY)); mode_t flags = O_WRONLY | (FileExists(dest) ? O_TRUNC : O_CREAT); CFDWrapper out(Open(dest.c_str(), flags)); char buffer[1024]; size_t size; while((size = Read(in, buffer, sizeof(buffer)))) { int b = Write(out, buffer, size); if (cb) cb(b, prvdata); } // Copy file permissions struct stat st; FStat(in, &st); // Disable umask temporary so we can normally copy permissions mode_t mask = umask(0); FChMod(out, st.st_mode); umask(mask); }
/* boolean IsLinkNotInCal (in nsIDOMNode node); */ NS_IMETHODIMP nsDomAttUtil::IsLinkNotInCal(nsIDOMNode *node, PRBool *_retval ) { PRBool bisLink=false; IsLink(node, &bisLink); if(bisLink) { nsCString content; GetNodeText(node, content); int date=atoi(content.get()); if(content.Length()<3&&date>0&&date<31) *_retval=PR_FALSE; else *_retval=PR_TRUE; }else { *_retval=PR_FALSE; } return NS_OK; }
void cTCPLinkImpl::ReadCallback(bufferevent * a_BufferEvent, void * a_Self) { ASSERT(a_Self != nullptr); cTCPLinkImpl * Self = static_cast<cTCPLinkImpl *>(a_Self); ASSERT(Self->m_BufferEvent == a_BufferEvent); ASSERT(Self->m_Callbacks != nullptr); // Read all the incoming data, in 1024-byte chunks: char data[1024]; size_t length; auto tlsContext = Self->m_TlsContext; while ((length = bufferevent_read(a_BufferEvent, data, sizeof(data))) > 0) { if (tlsContext != nullptr) { ASSERT(tlsContext->IsLink(Self)); tlsContext->StoreReceivedData(data, length); } else { Self->ReceivedCleartextData(data, length); } } }
bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,size_t HeaderSize,bool &Repeat) { char Command=*Cmd->Command; if (HeaderSize==0) if (DataIO.UnpVolume) { #ifdef NOVOLUME return(false); #else if (!MergeArchive(Arc,&DataIO,false,Command)) { ErrHandler.SetErrorCode(WARNING); return(false); } SignatureFound=false; #endif } else return(false); int HeadType=Arc.GetHeaderType(); if (HeadType!=FILE_HEAD) { if (HeadType==AV_HEAD || HeadType==SIGN_HEAD) SignatureFound=true; #if !defined(SFX_MODULE) && !defined(_WIN_CE) if (HeadType==SUB_HEAD && PrevExtracted) SetExtraInfo(Cmd,Arc,DestFileName,*DestFileNameW ? DestFileNameW:NULL); #endif if (HeadType==NEWSUB_HEAD) { if (Arc.SubHead.CmpName(SUBHEAD_TYPE_AV)) SignatureFound=true; #if !defined(NOSUBBLOCKS) && !defined(_WIN_CE) if (PrevExtracted) SetExtraInfoNew(Cmd,Arc,DestFileName,*DestFileNameW ? DestFileNameW:NULL); #endif } if (HeadType==ENDARC_HEAD) if (Arc.EndArcHead.Flags & EARC_NEXT_VOLUME) { #ifndef NOVOLUME if (!MergeArchive(Arc,&DataIO,false,Command)) { ErrHandler.SetErrorCode(WARNING); return(false); } SignatureFound=false; #endif Arc.Seek(Arc.CurBlockPos,SEEK_SET); return(true); } else return(false); Arc.SeekToNext(); return(true); } PrevExtracted=false; if (SignatureFound || !Cmd->Recurse && MatchedArgs>=Cmd->FileArgs->ItemsCount() && AllMatchesExact) return(false); char ArcFileName[NM]; IntToExt(Arc.NewLhd.FileName,Arc.NewLhd.FileName); strcpy(ArcFileName,Arc.NewLhd.FileName); wchar ArcFileNameW[NM]; *ArcFileNameW=0; int MatchType=MATCH_WILDSUBPATH; bool EqualNames=false; int MatchNumber=Cmd->IsProcessFile(Arc.NewLhd,&EqualNames,MatchType); bool ExactMatch=MatchNumber!=0; #if !defined(SFX_MODULE) && !defined(_WIN_CE) if (Cmd->ExclPath==EXCL_BASEPATH) { *Cmd->ArcPath=0; if (ExactMatch) { Cmd->FileArgs->Rewind(); if (Cmd->FileArgs->GetString(Cmd->ArcPath,NULL,sizeof(Cmd->ArcPath),MatchNumber-1)) *PointToName(Cmd->ArcPath)=0; } } #endif if (ExactMatch && !EqualNames) AllMatchesExact=false; #ifdef UNICODE_SUPPORTED bool WideName=(Arc.NewLhd.Flags & LHD_UNICODE) && UnicodeEnabled(); #else bool WideName=false; #endif #ifdef _APPLE if (WideName) { WideToUtf(Arc.NewLhd.FileNameW,ArcFileName,sizeof(ArcFileName)); WideName=false; } #endif wchar *DestNameW=WideName ? DestFileNameW:NULL; #ifdef UNICODE_SUPPORTED if (WideName) { ConvertPath(Arc.NewLhd.FileNameW,ArcFileNameW); char Name[NM]; if (WideToChar(ArcFileNameW,Name) && IsNameUsable(Name)) strcpy(ArcFileName,Name); } #endif ConvertPath(ArcFileName,ArcFileName); if (Arc.IsArcLabel()) return(true); if (Arc.NewLhd.Flags & LHD_VERSION) { if (Cmd->VersionControl!=1 && !EqualNames) { if (Cmd->VersionControl==0) ExactMatch=false; int Version=ParseVersionFileName(ArcFileName,ArcFileNameW,false); if (Cmd->VersionControl-1==Version) ParseVersionFileName(ArcFileName,ArcFileNameW,true); else ExactMatch=false; } } else if (!Arc.IsArcDir() && Cmd->VersionControl>1) ExactMatch=false; Arc.ConvertAttributes(); #ifndef SFX_MODULE if ((Arc.NewLhd.Flags & (LHD_SPLIT_BEFORE/*|LHD_SOLID*/)) && FirstFile) { char CurVolName[NM]; strcpy(CurVolName,ArcName); VolNameToFirstName(ArcName,ArcName,(Arc.NewMhd.Flags & MHD_NEWNUMBERING)!=0); if (stricomp(ArcName,CurVolName)!=0 && FileExist(ArcName)) { *ArcNameW=0; Repeat=true; return(false); } #if !defined(RARDLL) && !defined(_WIN_CE) if (!ReconstructDone) { ReconstructDone=true; RecVolumes RecVol; if (RecVol.Restore(Cmd,Arc.FileName,Arc.FileNameW,true)) { Repeat=true; return(false); } } #endif strcpy(ArcName,CurVolName); } #endif DataIO.UnpVolume=(Arc.NewLhd.Flags & LHD_SPLIT_AFTER)!=0; DataIO.NextVolumeMissing=false; Arc.Seek(Arc.NextBlockPos-Arc.NewLhd.FullPackSize,SEEK_SET); bool TestMode=false; bool ExtrFile=false; bool SkipSolid=false; #ifndef SFX_MODULE if (FirstFile && (ExactMatch || Arc.Solid) && (Arc.NewLhd.Flags & (LHD_SPLIT_BEFORE/*|LHD_SOLID*/))!=0) { if (ExactMatch) { Log(Arc.FileName,St(MUnpCannotMerge),ArcFileName); #ifdef RARDLL Cmd->DllError=ERAR_BAD_DATA; #endif ErrHandler.SetErrorCode(OPEN_ERROR); } ExactMatch=false; } FirstFile=false; #endif if (ExactMatch || (SkipSolid=Arc.Solid)!=0) { if ((Arc.NewLhd.Flags & LHD_PASSWORD)!=0) #ifndef RARDLL if (*Password==0) #endif { #ifdef RARDLL if (*Cmd->Password==0) if (Cmd->Callback==NULL || Cmd->Callback(UCM_NEEDPASSWORD,Cmd->UserData,(LPARAM)Cmd->Password,sizeof(Cmd->Password))==-1) return(false); strcpy(Password,Cmd->Password); #else if (!GetPassword(PASSWORD_FILE,ArcFileName,Password,sizeof(Password))) { PasswordCancelled=true; return(false); } #endif } #if !defined(GUI) && !defined(SILENT) else if (!PasswordAll && (!Arc.Solid || Arc.NewLhd.UnpVer>=20 && (Arc.NewLhd.Flags & LHD_SOLID)==0)) { eprintf(St(MUseCurPsw),ArcFileName); switch(Cmd->AllYes ? 1:Ask(St(MYesNoAll))) { case -1: ErrHandler.Exit(USER_BREAK); case 2: if (!GetPassword(PASSWORD_FILE,ArcFileName,Password,sizeof(Password))) { return(false); } break; case 3: PasswordAll=true; break; } } #endif #ifndef SFX_MODULE if (*Cmd->ExtrPath==0 && *Cmd->ExtrPathW!=0) WideToChar(Cmd->ExtrPathW,DestFileName); else #endif strcpy(DestFileName,Cmd->ExtrPath); #ifndef SFX_MODULE if (Cmd->AppendArcNameToPath) { strcat(DestFileName,PointToName(Arc.FirstVolumeName)); SetExt(DestFileName,NULL); AddEndSlash(DestFileName); } #endif char *ExtrName=ArcFileName; bool EmptyName=false; #ifndef SFX_MODULE size_t Length=strlen(Cmd->ArcPath); if (Length>1 && IsPathDiv(Cmd->ArcPath[Length-1]) && strlen(ArcFileName)==Length-1) Length--; if (Length>0 && strnicomp(Cmd->ArcPath,ArcFileName,Length)==0) { ExtrName+=Length; while (*ExtrName==CPATHDIVIDER) ExtrName++; if (*ExtrName==0) EmptyName=true; } #endif bool AbsPaths=Cmd->ExclPath==EXCL_ABSPATH && Command=='X' && IsDriveDiv(':'); if (AbsPaths) *DestFileName=0; if (Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH) strcat(DestFileName,PointToName(ExtrName)); else strcat(DestFileName,ExtrName); char DiskLetter=etoupper(DestFileName[0]); if (AbsPaths && DestFileName[1]=='_' && IsPathDiv(DestFileName[2]) && DiskLetter>='A' && DiskLetter<='Z') DestFileName[1]=':'; #ifndef SFX_MODULE if (!WideName && *Cmd->ExtrPathW!=0) { DestNameW=DestFileNameW; WideName=true; CharToWide(ArcFileName,ArcFileNameW); } #endif if (WideName) { if (*Cmd->ExtrPathW!=0) strcpyw(DestFileNameW,Cmd->ExtrPathW); else CharToWide(Cmd->ExtrPath,DestFileNameW); #ifndef SFX_MODULE if (Cmd->AppendArcNameToPath) { wchar FileNameW[NM]; if (*Arc.FirstVolumeNameW!=0) strcpyw(FileNameW,Arc.FirstVolumeNameW); else CharToWide(Arc.FirstVolumeName,FileNameW); strcatw(DestFileNameW,PointToName(FileNameW)); SetExt(DestFileNameW,NULL); AddEndSlash(DestFileNameW); } #endif wchar *ExtrNameW=ArcFileNameW; #ifndef SFX_MODULE if (Length>0) { wchar ArcPathW[NM]; GetWideName(Cmd->ArcPath,Cmd->ArcPathW,ArcPathW); Length=strlenw(ArcPathW); } ExtrNameW+=Length; while (*ExtrNameW==CPATHDIVIDER) ExtrNameW++; #endif if (AbsPaths) *DestFileNameW=0; if (Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH) strcatw(DestFileNameW,PointToName(ExtrNameW)); else strcatw(DestFileNameW,ExtrNameW); if (AbsPaths && DestFileNameW[1]=='_' && IsPathDiv(DestFileNameW[2])) DestFileNameW[1]=':'; } else *DestFileNameW=0; ExtrFile=!SkipSolid && !EmptyName && (Arc.NewLhd.Flags & LHD_SPLIT_BEFORE)==0; if ((Cmd->FreshFiles || Cmd->UpdateFiles) && (Command=='E' || Command=='X')) { struct FindData FD; if (FindFile::FastFind(DestFileName,DestNameW,&FD)) { if (FD.mtime >= Arc.NewLhd.mtime) { // If directory already exists and its modification time is newer // than start of extraction, it is likely it was created // when creating a path to one of already extracted items. // In such case we'll better update its time even if archived // directory is older. if (!FD.IsDir || FD.mtime<StartTime) ExtrFile=false; } } else if (Cmd->FreshFiles) ExtrFile=false; } // Skip encrypted file if no password is specified. if ((Arc.NewLhd.Flags & LHD_PASSWORD)!=0 && *Password==0) { ErrHandler.SetErrorCode(WARNING); #ifdef RARDLL Cmd->DllError=ERAR_MISSING_PASSWORD; #endif ExtrFile=false; } #ifdef RARDLL if (*Cmd->DllDestName) { strncpyz(DestFileName,Cmd->DllDestName,ASIZE(DestFileName)); *DestFileNameW=0; if (Cmd->DllOpMode!=RAR_EXTRACT) ExtrFile=false; } if (*Cmd->DllDestNameW) { strncpyzw(DestFileNameW,Cmd->DllDestNameW,ASIZE(DestFileNameW)); DestNameW=DestFileNameW; if (Cmd->DllOpMode!=RAR_EXTRACT) ExtrFile=false; } #endif #ifdef SFX_MODULE if ((Arc.NewLhd.UnpVer!=UNP_VER && Arc.NewLhd.UnpVer!=29) && Arc.NewLhd.Method!=0x30) #else if (Arc.NewLhd.UnpVer<13 || Arc.NewLhd.UnpVer>UNP_VER) #endif { #ifndef SILENT Log(Arc.FileName,St(MUnknownMeth),ArcFileName); #ifndef SFX_MODULE Log(Arc.FileName,St(MVerRequired),Arc.NewLhd.UnpVer/10,Arc.NewLhd.UnpVer%10); #endif #endif ExtrFile=false; ErrHandler.SetErrorCode(WARNING); #ifdef RARDLL Cmd->DllError=ERAR_UNKNOWN_FORMAT; #endif } File CurFile; if (!IsLink(Arc.NewLhd.FileAttr)) if (Arc.IsArcDir()) { if (!ExtrFile || Command=='P' || Command=='E' || Cmd->ExclPath==EXCL_SKIPWHOLEPATH) return(true); if (SkipSolid) { #ifndef GUI mprintf(St(MExtrSkipFile),ArcFileName); #endif return(true); } TotalFileCount++; if (Cmd->Test) { #ifndef GUI mprintf(St(MExtrTestFile),ArcFileName); mprintf(" %s",St(MOk)); #endif return(true); } MKDIR_CODE MDCode=MakeDir(DestFileName,DestNameW,!Cmd->IgnoreGeneralAttr,Arc.NewLhd.FileAttr); bool DirExist=false; if (MDCode!=MKDIR_SUCCESS) { DirExist=FileExist(DestFileName,DestNameW); if (DirExist && !IsDir(GetFileAttr(DestFileName,DestNameW))) { bool UserReject; FileCreate(Cmd,NULL,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime); DirExist=false; } CreatePath(DestFileName,DestNameW,true); MDCode=MakeDir(DestFileName,DestNameW,!Cmd->IgnoreGeneralAttr,Arc.NewLhd.FileAttr); } if (MDCode==MKDIR_SUCCESS) { #ifndef GUI mprintf(St(MCreatDir),DestFileName); mprintf(" %s",St(MOk)); #endif PrevExtracted=true; } else if (DirExist) { if (!Cmd->IgnoreGeneralAttr) SetFileAttr(DestFileName,DestNameW,Arc.NewLhd.FileAttr); PrevExtracted=true; } else { Log(Arc.FileName,St(MExtrErrMkDir),DestFileName); ErrHandler.SysErrMsg(); #ifdef RARDLL Cmd->DllError=ERAR_ECREATE; #endif ErrHandler.SetErrorCode(CREATE_ERROR); } if (PrevExtracted) { #if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) if (Cmd->SetCompressedAttr && (Arc.NewLhd.FileAttr & FILE_ATTRIBUTE_COMPRESSED)!=0 && WinNT()) SetFileCompression(DestFileName,DestNameW,true); #endif SetDirTime(DestFileName,DestNameW, Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime, Cmd->xctime==EXTTIME_NONE ? NULL:&Arc.NewLhd.ctime, Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime); } return(true); } else { if (Cmd->Test && ExtrFile) TestMode=true; #if !defined(GUI) && !defined(SFX_MODULE) if (Command=='P' && ExtrFile) CurFile.SetHandleType(FILE_HANDLESTD); #endif if ((Command=='E' || Command=='X') && ExtrFile && !Cmd->Test) { bool UserReject; if (!FileCreate(Cmd,&CurFile,DestFileName,DestNameW,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime)) { ExtrFile=false; if (!UserReject) { ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName); ErrHandler.SetErrorCode(CREATE_ERROR); #ifdef RARDLL Cmd->DllError=ERAR_ECREATE; #endif if (!IsNameUsable(DestFileName)) { Log(Arc.FileName,St(MCorrectingName)); char OrigName[sizeof(DestFileName)]; strncpyz(OrigName,DestFileName,ASIZE(OrigName)); MakeNameUsable(DestFileName,true); CreatePath(DestFileName,NULL,true); if (FileCreate(Cmd,&CurFile,DestFileName,NULL,Cmd->Overwrite,&UserReject,Arc.NewLhd.FullUnpSize,Arc.NewLhd.FileTime)) { #ifndef SFX_MODULE Log(Arc.FileName,St(MRenaming),OrigName,DestFileName); #endif ExtrFile=true; } else ErrHandler.CreateErrorMsg(Arc.FileName,DestFileName); } } } } } if (!ExtrFile && Arc.Solid) { SkipSolid=true; TestMode=true; ExtrFile=true; } if (ExtrFile) { if (!SkipSolid) { if (!TestMode && Command!='P' && CurFile.IsDevice()) { Log(Arc.FileName,St(MInvalidName),DestFileName); ErrHandler.WriteError(Arc.FileName,DestFileName); } TotalFileCount++; } FileCount++; #ifndef GUI if (Command!='I') if (SkipSolid) mprintf(St(MExtrSkipFile),ArcFileName); else switch(Cmd->Test ? 'T':Command) { case 'T': mprintf(St(MExtrTestFile),ArcFileName); break; #ifndef SFX_MODULE case 'P': mprintf(St(MExtrPrinting),ArcFileName); break; #endif case 'X': case 'E': mprintf(St(MExtrFile),DestFileName); break; } if (!Cmd->DisablePercentage) mprintf(" "); #endif DataIO.CurUnpRead=0; DataIO.CurUnpWrite=0; DataIO.UnpFileCRC=Arc.OldFormat ? 0 : 0xffffffff; DataIO.PackedCRC=0xffffffff; DataIO.SetEncryption( (Arc.NewLhd.Flags & LHD_PASSWORD) ? Arc.NewLhd.UnpVer:0,Password, (Arc.NewLhd.Flags & LHD_SALT) ? Arc.NewLhd.Salt:NULL,false, Arc.NewLhd.UnpVer>=36); DataIO.SetPackedSizeToRead(Arc.NewLhd.FullPackSize); DataIO.SetFiles(&Arc,&CurFile); DataIO.SetTestMode(TestMode); DataIO.SetSkipUnpCRC(SkipSolid); #ifndef _WIN_CE if (!TestMode && !Arc.BrokenFileHeader && (Arc.NewLhd.FullPackSize<<11)>Arc.NewLhd.FullUnpSize && (Arc.NewLhd.FullUnpSize<100000000 || Arc.FileLength()>Arc.NewLhd.FullPackSize)) CurFile.Prealloc(Arc.NewLhd.FullUnpSize); #endif CurFile.SetAllowDelete(!Cmd->KeepBroken); bool LinkCreateMode=!Cmd->Test && !SkipSolid; if (ExtractLink(DataIO,Arc,DestFileName,DataIO.UnpFileCRC,LinkCreateMode)) PrevExtracted=LinkCreateMode; else if ((Arc.NewLhd.Flags & LHD_SPLIT_BEFORE)==0) if (Arc.NewLhd.Method==0x30) UnstoreFile(DataIO,Arc.NewLhd.FullUnpSize); else { Unp->SetDestSize(Arc.NewLhd.FullUnpSize); #ifndef SFX_MODULE if (Arc.NewLhd.UnpVer<=15) Unp->DoUnpack(15,FileCount>1 && Arc.Solid); else #endif Unp->DoUnpack(Arc.NewLhd.UnpVer,(Arc.NewLhd.Flags & LHD_SOLID)!=0); } if (Arc.IsOpened()) Arc.SeekToNext(); bool BrokenFile=false; if (!SkipSolid) { if (Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC) || !Arc.OldFormat && UINT32(DataIO.UnpFileCRC)==UINT32(Arc.NewLhd.FileCRC^0xffffffff)) { #ifndef GUI if (Command!='P' && Command!='I') mprintf("%s%s ",Cmd->DisablePercentage ? " ":"\b\b\b\b\b ",St(MOk)); #endif } else { char *BadArcName=/*(Arc.NewLhd.Flags & LHD_SPLIT_BEFORE) ? NULL:*/Arc.FileName; if (Arc.NewLhd.Flags & LHD_PASSWORD) { Log(BadArcName,St(MEncrBadCRC),ArcFileName); } else { Log(BadArcName,St(MCRCFailed),ArcFileName); } BrokenFile=true; ErrHandler.SetErrorCode(CRC_ERROR); #ifdef RARDLL Cmd->DllError=ERAR_BAD_DATA; #endif Alarm(); } } #ifndef GUI else mprintf("\b\b\b\b\b "); #endif if (!TestMode && (Command=='X' || Command=='E') && !IsLink(Arc.NewLhd.FileAttr)) { #if defined(_WIN_32) || defined(_EMX) if (Cmd->ClearArc) Arc.NewLhd.FileAttr&=~FA_ARCH; /* else Arc.NewLhd.FileAttr|=FA_ARCH; //set archive bit for unpacked files (file is not backed up) */ #endif if (!BrokenFile || Cmd->KeepBroken) { if (BrokenFile) CurFile.Truncate(); CurFile.SetOpenFileTime( Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime, Cmd->xctime==EXTTIME_NONE ? NULL:&Arc.NewLhd.ctime, Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime); CurFile.Close(); #if defined(_WIN_32) && !defined(_WIN_CE) && !defined(SFX_MODULE) if (Cmd->SetCompressedAttr && (Arc.NewLhd.FileAttr & FILE_ATTRIBUTE_COMPRESSED)!=0 && WinNT()) SetFileCompression(CurFile.FileName,CurFile.FileNameW,true); #endif CurFile.SetCloseFileTime( Cmd->xmtime==EXTTIME_NONE ? NULL:&Arc.NewLhd.mtime, Cmd->xatime==EXTTIME_NONE ? NULL:&Arc.NewLhd.atime); if (!Cmd->IgnoreGeneralAttr) SetFileAttr(CurFile.FileName,CurFile.FileNameW,Arc.NewLhd.FileAttr); PrevExtracted=true; } } } } if (ExactMatch) MatchedArgs++; if (DataIO.NextVolumeMissing || !Arc.IsOpened()) return(false); if (!ExtrFile) if (!Arc.Solid) Arc.SeekToNext(); else if (!SkipSolid) return(false); return(true); }
bool 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; }
already_AddRefed<nsIURI> SVGAElement::GetHrefURI() const { nsCOMPtr<nsIURI> hrefURI; return IsLink(getter_AddRefs(hrefURI)) ? hrefURI.forget() : nullptr; }
static unrar_err_t next_( unrar_t* p, bool skipping_solid ) { if ( p->done ) return unrar_err_arc_eof; free( p->own_data_ ); p->own_data_ = NULL; p->data_ = NULL; for (;;) { size_t ReadSize; p->Arc.SeekToNext(); unrar_err_t const err = p->Arc.ReadHeader(&ReadSize); if ( err != unrar_err_arc_eof ) RETURN_ERR( err ); //else // debug_printf( "unrar: Didn't end with ENDARC_HEAD\n" ); // rar -en causes this HEADER_TYPE const type = (HEADER_TYPE) p->Arc.GetHeaderType(); if ( err != unrar_ok || type == HEAD_ENDARC ) { p->done = true; break; } if ( type != HEAD_FILE ) { // Skip non-files #if 0 if ( type != HEAD_SERVICE && type != HEAD_CRYPT && type != HEAD_MARK ) debug_printf( "unrar: Skipping unknown block type: %X\n", (unsigned) type ); #endif update_solid_pos( p ); } else { // Update even for non-solid files, in case it's not extracted if ( !solid_file( p ) ) update_solid_pos( p ); if ( p->Arc.IsArcLabel() ) { // Ignore labels } else if ( IsLink( p->Arc.FileHead.FileAttr ) ) { // Ignore links p->update_first_file_pos(); p->FileCount++; // Links are treated as files } else if ( p->Arc.IsArcDir() ) { // Ignore directories } else { p->info.size = p->Arc.FileHead.UnpSize; p->info.name_w = p->Arc.FileHead.FileName; WideToChar(p->info.name_w, p->info.name); p->info.is_unicode = (p->Arc.FileHead.Flags & LHD_UNICODE) != 0; p->info.dos_date = p->Arc.FileHead.mtime.GetDos(); p->info.crc = p->Arc.FileHead.FileHash.CRC32; p->info.is_crc32 = !p->Arc.OldFormat; // Stop for files break; } // Original code assumed that non-file items were never solid compressed check( !solid_file( p ) ); // Skip non-file solid-compressed items (original code assumed there were none) if ( skipping_solid ) RETURN_ERR( skip_solid( p ) ); } } return unrar_ok; }
int CALLBACK GetMemoData( LPVOID lp, int nGetType, LPVOID lpData, int nDataSize) { switch( nGetType) { case _GET_MEMO: return GetMemo( lp, lpData, nDataSize); case _GET_TITLE: return GetTitle( lp, lpData, nDataSize); case _GET_FONT: return GetFont( lp, lpData, nDataSize); case _GET_FORECOLOR: return GetForeColor( lp, lpData, nDataSize); case _GET_BACKCOLOR: return GetBackColor( lp, lpData, nDataSize); case _GET_ICON: return GetIconIndex( lp); case _GET_ZORDER: return GetZOrder( lp); case _GET_WINDOWTYPE: return GetWindowType( lp); case _GET_RECT_NORMAL: return GetNormalRect( lp, lpData, nDataSize); case _GET_POINT_TITLE: return GetTitlePoint( lp, lpData, nDataSize); case _GET_POINT_ICON: return GetIconPoint( lp, lpData, nDataSize); case _GET_RECT_TITLE: return GetTitleRect( lp, lpData, nDataSize); case _GET_RECT_ICON: return GetIconRect( lp, lpData, nDataSize); case _GET_TIMERENABLE: return IsTimerEnable( lp); case _GET_TIMER_TYPE: return GetTimerType( lp); case _GET_TIMER_MONTH: return GetTimerMonth( lp); case _GET_TIMER_DAY: return GetTimerDay( lp); case _GET_TIMER_HOUR: return GetTimerHour( lp); case _GET_TIMER_MIN: return GetTimerMin( lp); case _GET_TIMER_WEEK: return GetTimerWeek( lp); case _GET_TIMER_SOUND: return GetTimerSound( lp, lpData, nDataSize); case _GET_LINKENABLE: return IsLink( lp); case _GET_LINK_FILE: return GetLinkFile( lp, lpData, nDataSize); case _GET_LINK_PARAM: return GetLinkParam( lp, lpData, nDataSize); case _GET_CREATE_YEAR: return GetCreateYear( lp); case _GET_CREATE_MONTH: return GetCreateMonth( lp); case _GET_CREATE_DAY: return GetCreateDay( lp); case _GET_DEF_FONT: return GetDefFont( lpData, nDataSize); case _GET_DEF_FORECLR: return GetDefForeColor( lpData, nDataSize); case _GET_DEF_BACKCLR: return GetDefBackColor( lpData, nDataSize); case _GET_VERSION: return VERSION_CODE; } return 0; }