MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / FastFind

Method FastFind

Libraries/unrar/find.cpp:108–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106
107
108bool FindFile::FastFind(const wchar *FindMask,FindData *fd,bool GetSymLink)
109{
110 fd->Error=false;
111#ifndef _UNIX
112 if (IsWildcard(FindMask))
113 return false;
114#endif
115#ifdef _WIN_ALL
116 HANDLE hFind=Win32Find(INVALID_HANDLE_VALUE,FindMask,fd);
117 if (hFind==INVALID_HANDLE_VALUE)
118 return false;
119 FindClose(hFind);
120#else
121 char FindMaskA[NM];
122 WideToChar(FindMask,FindMaskA,ASIZE(FindMaskA));
123
124 struct stat st;
125 if (GetSymLink)
126 {
127#ifdef SAVE_LINKS
128 if (lstat(FindMaskA,&st)!=0)
129#else
130 if (stat(FindMaskA,&st)!=0)
131#endif
132 {
133 fd->Error=(errno!=ENOENT);
134 return false;
135 }
136 }
137 else
138 if (stat(FindMaskA,&st)!=0)
139 {
140 fd->Error=(errno!=ENOENT);
141 return false;
142 }
143 fd->FileAttr=st.st_mode;
144 fd->Size=st.st_size;
145
146#ifdef UNIX_TIME_NS
147 fd->mtime.SetUnixNS(st.st_mtim.tv_sec*(uint64)1000000000+st.st_mtim.tv_nsec);
148 fd->atime.SetUnixNS(st.st_atim.tv_sec*(uint64)1000000000+st.st_atim.tv_nsec);
149 fd->ctime.SetUnixNS(st.st_ctim.tv_sec*(uint64)1000000000+st.st_ctim.tv_nsec);
150#else
151 fd->mtime.SetUnix(st.st_mtime);
152 fd->atime.SetUnix(st.st_atime);
153 fd->ctime.SetUnix(st.st_ctime);
154#endif
155
156 wcsncpyz(fd->Name,FindMask,ASIZE(fd->Name));
157#endif
158 fd->Flags=0;
159 fd->IsDir=IsDir(fd->FileAttr);
160 fd->IsLink=IsLink(fd->FileAttr);
161
162 return true;
163}
164
165

Callers

nothing calls this directly

Calls 8

IsWildcardFunction · 0.85
WideToCharFunction · 0.85
wcsncpyzFunction · 0.85
IsDirFunction · 0.85
IsLinkFunction · 0.85
SetUnixNSMethod · 0.80
SetUnixMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected