@@ -144,8 +144,8 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName,
144
144
StringRef InterndDirName = NamedDirEnt.first ();
145
145
146
146
// Check to see if the directory exists.
147
- FileData Data ;
148
- if (getStatValue (InterndDirName, Data , false , nullptr /* directory lookup*/ )) {
147
+ llvm::vfs::Status Status ;
148
+ if (getStatValue (InterndDirName, Status , false , nullptr /* directory lookup*/ )) {
149
149
// There's no real directory at the given path.
150
150
if (!CacheFailure)
151
151
SeenDirEntries.erase (DirName);
@@ -156,7 +156,7 @@ const DirectoryEntry *FileManager::getDirectory(StringRef DirName,
156
156
// same inode (this occurs on Unix-like systems when one dir is
157
157
// symlinked to another, for example) or the same path (on
158
158
// Windows).
159
- DirectoryEntry &UDE = UniqueRealDirs[Data. UniqueID ];
159
+ DirectoryEntry &UDE = UniqueRealDirs[Status. getUniqueID () ];
160
160
161
161
NamedDirEnt.second = &UDE;
162
162
if (UDE.getName ().empty ()) {
@@ -205,8 +205,8 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
205
205
206
206
// Check to see if the file exists.
207
207
std::unique_ptr<llvm::vfs::File> F;
208
- FileData Data ;
209
- if (getStatValue (InterndFileName, Data , true , openFile ? &F : nullptr )) {
208
+ llvm::vfs::Status Status ;
209
+ if (getStatValue (InterndFileName, Status , true , openFile ? &F : nullptr )) {
210
210
// There's no real file at the given path.
211
211
if (!CacheFailure)
212
212
SeenFileEntries.erase (Filename);
@@ -218,14 +218,15 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
218
218
219
219
// It exists. See if we have already opened a file with the same inode.
220
220
// This occurs when one dir is symlinked to another, for example.
221
- FileEntry &UFE = UniqueRealFiles[Data. UniqueID ];
221
+ FileEntry &UFE = UniqueRealFiles[Status. getUniqueID () ];
222
222
223
223
NamedFileEnt.second = &UFE;
224
224
225
225
// If the name returned by getStatValue is different than Filename, re-intern
226
226
// the name.
227
- if (Data.Name != Filename) {
228
- auto &NamedFileEnt = *SeenFileEntries.insert ({Data.Name , &UFE}).first ;
227
+ if (Status.getName () != Filename) {
228
+ auto &NamedFileEnt =
229
+ *SeenFileEntries.insert ({Status.getName (), &UFE}).first ;
229
230
assert (NamedFileEnt.second == &UFE &&
230
231
" filename from getStatValue() refers to wrong file" );
231
232
InterndFileName = NamedFileEnt.first ().data ();
@@ -239,7 +240,7 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
239
240
// module's structure when its headers/module map are mapped in the VFS.
240
241
// We should remove this as soon as we can properly support a file having
241
242
// multiple names.
242
- if (DirInfo != UFE.Dir && Data .IsVFSMapped )
243
+ if (DirInfo != UFE.Dir && Status .IsVFSMapped )
243
244
UFE.Dir = DirInfo;
244
245
245
246
// Always update the name to use the last name by which a file was accessed.
@@ -254,13 +255,12 @@ const FileEntry *FileManager::getFile(StringRef Filename, bool openFile,
254
255
255
256
// Otherwise, we don't have this file yet, add it.
256
257
UFE.Name = InterndFileName;
257
- UFE.Size = Data. Size ;
258
- UFE.ModTime = Data. ModTime ;
258
+ UFE.Size = Status. getSize () ;
259
+ UFE.ModTime = llvm::sys::toTimeT (Status. getLastModificationTime ()) ;
259
260
UFE.Dir = DirInfo;
260
261
UFE.UID = NextFileUID++;
261
- UFE.UniqueID = Data.UniqueID ;
262
- UFE.IsNamedPipe = Data.IsNamedPipe ;
263
- UFE.InPCH = Data.InPCH ;
262
+ UFE.UniqueID = Status.getUniqueID ();
263
+ UFE.IsNamedPipe = Status.getType () == llvm::sys::fs::file_type::fifo_file;
264
264
UFE.File = std::move (F);
265
265
UFE.IsValid = true ;
266
266
@@ -298,12 +298,15 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size,
298
298
" The directory of a virtual file should already be in the cache." );
299
299
300
300
// Check to see if the file exists. If so, drop the virtual file
301
- FileData Data ;
301
+ llvm::vfs::Status Status ;
302
302
const char *InterndFileName = NamedFileEnt.first ().data ();
303
- if (getStatValue (InterndFileName, Data, true , nullptr ) == 0 ) {
304
- Data.Size = Size ;
305
- Data.ModTime = ModificationTime;
306
- UFE = &UniqueRealFiles[Data.UniqueID ];
303
+ if (getStatValue (InterndFileName, Status, true , nullptr ) == 0 ) {
304
+ UFE = &UniqueRealFiles[Status.getUniqueID ()];
305
+ Status = llvm::vfs::Status (
306
+ Status.getName (), Status.getUniqueID (),
307
+ llvm::sys::toTimePoint (ModificationTime),
308
+ Status.getUser (), Status.getGroup (), Size ,
309
+ Status.getType (), Status.getPermissions ());
307
310
308
311
NamedFileEnt.second = UFE;
309
312
@@ -317,10 +320,9 @@ FileManager::getVirtualFile(StringRef Filename, off_t Size,
317
320
if (UFE->isValid ())
318
321
return UFE;
319
322
320
- UFE->UniqueID = Data.UniqueID ;
321
- UFE->IsNamedPipe = Data.IsNamedPipe ;
322
- UFE->InPCH = Data.InPCH ;
323
- fillRealPathName (UFE, Data.Name );
323
+ UFE->UniqueID = Status.getUniqueID ();
324
+ UFE->IsNamedPipe = Status.getType () == llvm::sys::fs::file_type::fifo_file;
325
+ fillRealPathName (UFE, Status.getName ());
324
326
} else {
325
327
VirtualFileEntries.push_back (llvm::make_unique<FileEntry>());
326
328
UFE = VirtualFileEntries.back ().get ();
@@ -421,17 +423,18 @@ FileManager::getBufferForFile(StringRef Filename, bool isVolatile) {
421
423
// / if the path points to a virtual file or does not exist, or returns
422
424
// / false if it's an existent real file. If FileDescriptor is NULL,
423
425
// / do directory look-up instead of file look-up.
424
- bool FileManager::getStatValue (StringRef Path, FileData &Data, bool isFile,
426
+ bool FileManager::getStatValue (StringRef Path, llvm::vfs::Status &Status,
427
+ bool isFile,
425
428
std::unique_ptr<llvm::vfs::File> *F) {
426
429
// FIXME: FileSystemOpts shouldn't be passed in here, all paths should be
427
430
// absolute!
428
431
if (FileSystemOpts.WorkingDir .empty ())
429
- return FileSystemStatCache::get (Path, Data , isFile, F,StatCache.get (), *FS);
432
+ return FileSystemStatCache::get (Path, Status , isFile, F,StatCache.get (), *FS);
430
433
431
434
SmallString<128 > FilePath (Path);
432
435
FixupRelativePath (FilePath);
433
436
434
- return FileSystemStatCache::get (FilePath.c_str (), Data , isFile, F,
437
+ return FileSystemStatCache::get (FilePath.c_str (), Status , isFile, F,
435
438
StatCache.get (), *FS);
436
439
}
437
440
0 commit comments