LLVM: include/llvm/Support/FileSystem.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef LLVM_SUPPORT_FILESYSTEM_H
27#define LLVM_SUPPORT_FILESYSTEM_H
28
32#include "llvm/Config/llvm-config.h"
40#include
41#include
42#include
43#include
44#include
45#include <system_error>
46#include
47
48namespace llvm {
49namespace sys {
51
52#if defined(_WIN32)
53
55#else
57#endif
58
60
61
74
75
81
106
107
109 return static_cast<perms>(static_cast<unsigned short>(l) |
110 static_cast<unsigned short>(r));
111}
113 return static_cast<perms>(static_cast<unsigned short>(l) &
114 static_cast<unsigned short>(r));
115}
117 l = l | r;
118 return l;
119}
121 l = l & r;
122 return l;
123}
125
126 return static_cast<perms>(
127 static_cast<unsigned short>(~static_cast(x)));
128}
129
130
131
132
134protected:
135 #if defined(LLVM_ON_UNIX)
143 #elif defined (_WIN32)
144 uint32_t LastAccessedTimeHigh = 0;
145 uint32_t LastAccessedTimeLow = 0;
146 uint32_t LastWriteTimeHigh = 0;
147 uint32_t LastWriteTimeLow = 0;
150 #endif
153
154public:
156
158
159 #if defined(LLVM_ON_UNIX)
162 uid_t UID, gid_t GID, off_t Size)
167#elif defined(_WIN32)
172 : LastAccessedTimeHigh(LastAccessTimeHigh),
173 LastAccessedTimeLow(LastAccessTimeLow),
174 LastWriteTimeHigh(LastWriteTimeHigh),
175 LastWriteTimeLow(LastWriteTimeLow), FileSizeHigh(FileSizeHigh),
177 #endif
178
179
182
183
184
185
186
188
189
190
191
192
193
194
195
197
198#if defined(LLVM_ON_UNIX)
202#elif defined(_WIN32)
204 return 9999;
205 }
206
208 return 9999;
209 }
210
212 return (uint64_t(FileSizeHigh) << 32) + FileSizeLow;
213 }
214#endif
215
216
219};
220
221
224
225#if defined(LLVM_ON_UNIX)
226 dev_t fs_st_dev = 0;
227 nlink_t fs_st_nlinks = 0;
228 ino_t fs_st_ino = 0;
229#elif defined(_WIN32)
231 uint32_t VolumeSerialNumber = 0;
233#endif
234
235public:
237
239
240 #if defined(LLVM_ON_UNIX)
242 time_t ATime, uint32_t ATimeNSec,
243 time_t MTime, uint32_t MTimeNSec,
244 uid_t UID, gid_t GID, off_t Size)
246 UID, GID, Size),
247 fs_st_dev(Dev), fs_st_nlinks(Links), fs_st_ino(Ino) {}
248 #elif defined(_WIN32)
255 LastWriteTimeHigh, LastWriteTimeLow, FileSizeHigh,
256 FileSizeLow),
257 NumLinks(LinkCount), VolumeSerialNumber(VolumeSerialNumber),
258 PathHash(PathHash) {}
259 #endif
260
263};
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
281
282
283
284
285
286
287
291
292
293
294
295
296
297
299 bool IgnoreExisting = true,
301
302
303
304
305
306
307
308
309
310
311
312
314
315
316
317
318
319
320
322
323
324
325
326
327
328
329
333
334
335
336
337
339
340
341
342
343
344
346
347
348
349
350
351
353
354
355
356
357
358
359
361 bool IgnoreNonExisting = true);
362
363
364
365
366
367
369 bool IgnoreErrors = true);
370
371
372
373
374
375
376
377
378
380
381
382
383
384
386
387
388
389
390
392
393
394
395
396
397
398
400
401
402
403
405
406
407
408
409
412#ifdef _WIN32
413 (void)FD;
415 return std::error_code();
416#else
418#endif
419}
420
421
422
423
424
425
427
428
430
431
432
433
434
435
436
437
438
439
441
443
444
445
446
447
448
450
451
452
453
454
458
459
460
461
462
464
465
466
467
468
472
473
474
475
476
477
478
479
480
481
483
484
485
486
487
488
489
490
491
492
493
495 bool &result);
496
497
498
503
504
505
506
507
508
509
510
512
513
515
516
517
519 bool Result;
520 return (Path, Result) && Result;
521}
522
523
524
526 bool Result;
527 return (FD, Result) && Result;
528}
529
530
531
532
533
534
535
537
538
539
540
541
543
544
545
546
547
548
549
550
552
553
554
556 bool Result;
557 return (Path, Result) && Result;
558}
559
560
561
562
563
565
566
567
568
569
570
571
572
574
575
576
578 bool Result;
580 return false;
581 return Result;
582}
583
584
585
586
587
589
590
591
592
593
594
595
596
598
599
600
602 bool Result;
604 return false;
605 return Result;
606}
607
608
609
610
611
612
614
615
616
617
618
619
620
621
622
624
625
626
627
628
629
630
631
632
634 bool follow = true);
635
636
638
639#ifdef _WIN32
640
642#endif
643
644
645
646
647
648
649
651
652
653
654
655
656
657
658
659
660
662
663
664
665
667
668
669
670
671
672
673
674
675
677
678
679
680
681
682
683
687 if (EC)
688 return EC;
689 Result = Status.getSize();
690 return std::error_code();
691}
692
693
694
695
696
697
701
702
703
708
709
710
711
712
714
715
716
717
718
719
720
722
724
725
726
728
729
730
731
733
734
735
736
738
739
740
741
743};
744
749
752
753
754
756
757
758
760
761
762
763
765
766
768
769
770
772
773
774
776
777
778
780};
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
802 bool MakeAbsolute);
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
831
832
833
837
838
839
840
841
842
843
844
845class TempFile {
846 bool Done = false;
848
849public:
850
851
857
858
860
861
863
864#ifdef _WIN32
865
866 bool RemoveOnClose = false;
867#endif
868
869
871
872
874
875
877
878
880};
881
882
883
884
885
886
887
888
889
894
895
896
901
904
905
906
907
908
909
910
911
915
916
917
918
919
920
921
922
923
927
931
934 return A;
935}
936
940
943 return A;
944}
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
983 unsigned Mode = 0666);
984
985
986
987
989
990#ifndef _WIN32
992#endif
993
994
995
997
998
999
1001
1002
1003
1005
1006
1007
1008
1009
1010
1011
1012
1015
1016
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064inline std::error_code
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1087 unsigned Mode = 0666) {
1089}
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1109 unsigned Mode = 0666) {
1111}
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1129 unsigned Mode = 0666) {
1131}
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1166
1167
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1197 std::chrono::milliseconds Timeout = std::chrono::milliseconds(0),
1199
1200
1201
1202
1203
1204
1206
1207
1208
1209
1210
1211
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1224
1225#ifdef LLVM_ON_UNIX
1226
1227
1228
1229
1230
1231
1234#endif
1235
1236
1237class FileLocker {
1238 int FD;
1239 FileLocker(int FD) : FD(FD) {}
1241
1242public:
1244 FileLocker(FileLocker &&L) : FD(L.FD) { L.FD = -1; }
1246 if (FD != -1)
1248 }
1250 FD = L.FD;
1251 L.FD = -1;
1252 return *this;
1253 }
1254 FileLocker &operator=(const FileLocker &L) = delete;
1256 if (FD != -1) {
1257 std::error_code Result = unlockFile(FD);
1258 FD = -1;
1259 return Result;
1260 }
1261 return std::error_code();
1262 }
1263};
1264
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1277
1278
1279
1281public:
1287
1288private:
1289
1290 size_t Size = 0;
1291 void *Mapping = nullptr;
1292#ifdef _WIN32
1294#endif
1296
1298 Size = Copied.Size;
1299 Mapping = Copied.Mapping;
1300#ifdef _WIN32
1301 FileHandle = Copied.FileHandle;
1302#endif
1303 Mode = Copied.Mode;
1304 }
1305
1307 copyFrom(Moved);
1309 }
1310
1312 LLVM_ABI void dontNeedImpl();
1313
1315 mapmode Mode);
1316
1317public:
1322 moveFromImpl(Moved);
1323 return *this;
1324 }
1325
1328
1329
1331 uint64_t offset, std::error_code &ec);
1332
1334
1335
1336 explicit operator bool() const { return Mapping; }
1337
1338
1344
1347
1348
1349
1350
1352
1353
1354
1356
1357
1359};
1360
1361
1362
1363
1365
1366
1367
1368
1369
1370
1372
1373
1374
1375
1376
1377 std::string Path;
1379 bool FollowSymlinks = true;
1381
1382public:
1386 : Path(Path.str()), Type(Type), FollowSymlinks(FollowSymlinks),
1387 Status(Status) {}
1388
1390
1394
1395 const std::string &path() const { return Path; }
1396
1397
1398
1400
1401
1402
1409
1416};
1417
1419
1421
1426
1427
1436
1437}
1438
1439
1440
1441
1443 std::shared_ptrdetail::DirIterState State;
1444 bool FollowSymlinks = true;
1445
1446public:
1448 bool follow_symlinks = true)
1449 : FollowSymlinks(follow_symlinks) {
1450 State = std::make_shareddetail::DirIterState();
1453 *State, path.toStringRef(path_storage), FollowSymlinks);
1454 }
1455
1457 bool follow_symlinks = true)
1458 : FollowSymlinks(follow_symlinks) {
1459 State = std::make_shareddetail::DirIterState();
1461 *State, de.path(), FollowSymlinks);
1462 }
1463
1464
1466
1467
1469 ec = directory_iterator_increment(*State);
1470 return *this;
1471 }
1472
1475
1477 if (State == RHS.State)
1478 return true;
1479 if (.State)
1481 if (!State)
1483 return State->CurrentEntry == RHS.State->CurrentEntry;
1484 }
1485
1487 return !(*this == RHS);
1488 }
1489};
1490
1492
1493
1495 std::vector<directory_iterator> Stack;
1498 };
1499
1500}
1501
1502
1503
1505 std::shared_ptrdetail::RecDirIterState State;
1506 bool Follow;
1507
1508public:
1511 bool follow_symlinks = true)
1512 : State(std::make_shared<detail::RecDirIterState>()),
1513 Follow(follow_symlinks) {
1516 State.reset();
1517 }
1518
1519
1522
1523 if (State->HasNoPushRequest)
1524 State->HasNoPushRequest = false;
1525 else {
1526 file_type type = State->Stack.back()->type();
1528
1531 type = status->type();
1532
1533 }
1535 State->Stack.push_back(
1537 if (State->Stack.back() != end_itr) {
1538 ++State->Level;
1539 return *this;
1540 }
1541 State->Stack.pop_back();
1542 }
1543 }
1544
1545 while (!State->Stack.empty()
1546 && State->Stack.back().increment(ec) == end_itr) {
1547 State->Stack.pop_back();
1548 --State->Level;
1549 }
1550
1551
1552 if (State->Stack.empty())
1553 State.reset();
1554
1555 return *this;
1556 }
1557
1560
1561
1562
1563 int level() const { return State->Level; }
1564
1565
1567
1568
1569
1571 assert(State && "Cannot pop an end iterator!");
1572 assert(State->Level > 0 && "Cannot pop an iterator with level < 1");
1573
1575 std::error_code ec;
1576 do {
1577 if (ec)
1579 State->Stack.pop_back();
1580 --State->Level;
1581 } while (!State->Stack.empty()
1582 && State->Stack.back().increment(ec) == end_itr);
1583
1584
1585 if (State->Stack.empty())
1586 State.reset();
1587 }
1588
1589
1590 void no_push() { State->HasNoPushRequest = true; }
1591
1593 return State == RHS.State;
1594 }
1595
1597 return !(*this == RHS);
1598 }
1599};
1600
1601
1602
1603}
1604}
1605}
1606
1607#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static ManagedStatic< DebugCounterOwner > Owner
Provides ErrorOr smart pointer.
amode Optimize addressing mode
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file defines the SmallString class.
int file_t
Definition FileSystem.h:56
Represents either an error or a value T.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
A raw_ostream that writes to a file descriptor.
FileLocker & operator=(FileLocker &&L)
Definition FileSystem.h:1249
FileLocker(const FileLocker &L)=delete
FileLocker & operator=(const FileLocker &L)=delete
~FileLocker()
Definition FileSystem.h:1245
FileLocker(FileLocker &&L)
Definition FileSystem.h:1244
std::error_code unlock()
Definition FileSystem.h:1255
std::string TmpName
Definition FileSystem.h:859
int FD
Definition FileSystem.h:862
LLVM_ABI TempFile & operator=(TempFile &&Other)
static LLVM_ABI Expected< TempFile > create(const Twine &Model, unsigned Mode=all_read|all_write, OpenFlags ExtraFlags=OF_None)
This creates a temporary file with createUniqueFile and schedules it for deletion with sys::RemoveFil...
Represents the result of a call to directory_iterator::status().
Definition FileSystem.h:133
off_t fs_st_size
Definition FileSystem.h:142
uid_t fs_st_uid
Definition FileSystem.h:140
basic_file_status(file_type Type, perms Perms, time_t ATime, uint32_t ATimeNSec, time_t MTime, uint32_t MTimeNSec, uid_t UID, gid_t GID, off_t Size)
Definition FileSystem.h:160
void permissions(perms p)
Definition FileSystem.h:218
uint32_t fs_st_mtime_nsec
Definition FileSystem.h:139
basic_file_status()=default
perms Perms
Definition FileSystem.h:152
void type(file_type v)
Definition FileSystem.h:217
time_t fs_st_atime
Definition FileSystem.h:136
uint64_t getSize() const
Definition FileSystem.h:201
uint32_t fs_st_atime_nsec
Definition FileSystem.h:138
uint32_t getGroup() const
Definition FileSystem.h:200
LLVM_ABI TimePoint getLastModificationTime() const
The file modification time as reported from the underlying file system.
perms permissions() const
Definition FileSystem.h:181
gid_t fs_st_gid
Definition FileSystem.h:141
file_type type() const
Definition FileSystem.h:180
uint32_t getUser() const
Definition FileSystem.h:199
LLVM_ABI TimePoint getLastAccessedTime() const
The file access time as reported from the underlying file system.
time_t fs_st_mtime
Definition FileSystem.h:137
basic_file_status(file_type Type)
Definition FileSystem.h:157
file_type Type
Definition FileSystem.h:151
directory_entry - A single entry in a directory.
Definition FileSystem.h:1371
directory_entry(const Twine &Path, bool FollowSymlinks=true, file_type Type=file_type::type_unknown, basic_file_status Status=basic_file_status())
Definition FileSystem.h:1383
LLVM_ABI bool operator<=(const directory_entry &RHS) const
LLVM_ABI bool operator>(const directory_entry &RHS) const
LLVM_ABI bool operator>=(const directory_entry &RHS) const
LLVM_ABI bool operator<(const directory_entry &RHS) const
LLVM_ABI ErrorOr< basic_file_status > status() const
bool operator==(const directory_entry &RHS) const
Definition FileSystem.h:1410
bool operator!=(const directory_entry &RHS) const
Definition FileSystem.h:1411
file_type type() const
Definition FileSystem.h:1403
const std::string & path() const
Definition FileSystem.h:1395
directory_entry()=default
LLVM_ABI void replace_filename(const Twine &Filename, file_type Type, basic_file_status Status=basic_file_status())
directory_iterator - Iterates through the entries in path.
Definition FileSystem.h:1442
bool operator!=(const directory_iterator &RHS) const
Definition FileSystem.h:1486
directory_iterator(const directory_entry &de, std::error_code &ec, bool follow_symlinks=true)
Definition FileSystem.h:1456
directory_iterator(const Twine &path, std::error_code &ec, bool follow_symlinks=true)
Definition FileSystem.h:1447
directory_iterator()=default
Construct end iterator.
const directory_entry & operator*() const
Definition FileSystem.h:1473
directory_iterator & increment(std::error_code &ec)
Definition FileSystem.h:1468
bool operator==(const directory_iterator &RHS) const
Definition FileSystem.h:1476
const directory_entry * operator->() const
Definition FileSystem.h:1474
Represents the result of a call to sys::fs::status().
Definition FileSystem.h:222
file_status(file_type Type, perms Perms, dev_t Dev, nlink_t Links, ino_t Ino, time_t ATime, uint32_t ATimeNSec, time_t MTime, uint32_t MTimeNSec, uid_t UID, gid_t GID, off_t Size)
Definition FileSystem.h:241
LLVM_ABI uint32_t getLinkCount() const
LLVM_ABI friend bool equivalent(file_status A, file_status B)
Do file_status's represent the same thing?
file_status(file_type Type)
Definition FileSystem.h:238
LLVM_ABI UniqueID getUniqueID() const
This class represents a memory mapped file.
Definition FileSystem.h:1280
LLVM_ABI size_t size() const
LLVM_ABI std::error_code sync() const
Write changes to disk and synchronize.
mapped_file_region(mapped_file_region &&Moved)
Definition FileSystem.h:1319
~mapped_file_region()
Definition FileSystem.h:1333
mapped_file_region()=default
static LLVM_ABI int alignment()
mapmode
Definition FileSystem.h:1282
@ priv
May modify via data, but changes are lost on destruction.
Definition FileSystem.h:1285
@ readonly
May only access map via const_data as read only.
Definition FileSystem.h:1283
@ readwrite
May access map via data and modify it. Written to path.
Definition FileSystem.h:1284
void unmap()
Unmap.
Definition FileSystem.h:1339
mapped_file_region & operator=(mapped_file_region &&Moved)
Definition FileSystem.h:1320
LLVM_ABI const char * const_data() const
Get a const view of the data.
mapped_file_region(const mapped_file_region &)=delete
LLVM_ABI char * data() const
mapped_file_region & operator=(const mapped_file_region &)=delete
void dontNeed()
Definition FileSystem.h:1343
LLVM_ABI mapped_file_region(sys::fs::file_t fd, mapmode mode, size_t length, uint64_t offset, std::error_code &ec)
void pop()
Goes up one level if Level > 0.
Definition FileSystem.h:1570
bool operator==(const recursive_directory_iterator &RHS) const
Definition FileSystem.h:1592
void no_push()
Does not go down into the current directory_entry.
Definition FileSystem.h:1590
int level() const
Gets the current level. Starting path is at level 0.
Definition FileSystem.h:1563
const directory_entry * operator->() const
Definition FileSystem.h:1559
recursive_directory_iterator()=default
recursive_directory_iterator & increment(std::error_code &ec)
Definition FileSystem.h:1520
recursive_directory_iterator(const Twine &path, std::error_code &ec, bool follow_symlinks=true)
Definition FileSystem.h:1510
const directory_entry & operator*() const
Definition FileSystem.h:1558
bool no_push_request() const
Returns true if no_push has been called for this directory_entry.
Definition FileSystem.h:1566
bool operator!=(const recursive_directory_iterator &RHS) const
Definition FileSystem.h:1596
LLVM_ABI std::error_code directory_iterator_construct(DirIterState &, StringRef, bool)
LLVM_ABI std::error_code directory_iterator_destruct(DirIterState &)
LLVM_ABI std::error_code directory_iterator_increment(DirIterState &)
Definition FileSystem.h:50
LLVM_ABI bool is_regular_file(const basic_file_status &status)
Does status represent a regular file?
LLVM_ABI bool can_execute(const Twine &Path)
Can we execute this file?
LLVM_ABI bool is_symlink_file(const basic_file_status &status)
Does status represent a symlink file?
perms operator&(perms l, perms r)
Definition FileSystem.h:112
LLVM_ABI std::error_code closeFile(file_t &F)
Close the file object.
@ DefaultReadChunkSize
Definition FileSystem.h:1017
perms operator|(perms l, perms r)
Definition FileSystem.h:108
std::error_code openFileForReadWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
Definition FileSystem.h:1106
LLVM_ABI std::error_code rename(const Twine &from, const Twine &to)
Rename from to to.
LLVM_ABI Error readNativeFileToEOF(file_t FileHandle, SmallVectorImpl< char > &Buffer, ssize_t ChunkSize=DefaultReadChunkSize)
Reads from FileHandle until EOF, appending to Buffer in chunks of size ChunkSize.
perms & operator&=(perms &l, perms r)
Definition FileSystem.h:120
LLVM_ABI ErrorOr< perms > getPermissions(const Twine &Path)
Get file permissions.
bool can_write(const Twine &Path)
Can we write this file?
Definition FileSystem.h:469
LLVM_ABI std::error_code create_hard_link(const Twine &to, const Twine &from)
Create a hard link from from to to, or return an error.
perms operator~(perms x)
Definition FileSystem.h:124
LLVM_ABI std::error_code openFile(const Twine &Name, int &ResultFD, CreationDisposition Disp, FileAccess Access, OpenFlags Flags, unsigned Mode=0666)
Opens a file with the specified creation disposition, access mode, and flags and returns a file descr...
LLVM_ABI const file_t kInvalidFile
std::error_code resize_file_before_mapping_readwrite(int FD, uint64_t Size)
Resize FD to Size before mapping mapped_file_region::readwrite.
Definition FileSystem.h:410
LLVM_ABI std::error_code getPotentiallyUniqueFileName(const Twine &Model, SmallVectorImpl< char > &ResultPath)
Get a unique name, not currently exisiting in the filesystem.
LLVM_ABI std::error_code access(const Twine &Path, AccessMode Mode)
Can the file be accessed?
LLVM_ABI ErrorOr< space_info > disk_space(const Twine &Path)
Get disk space usage information.
LLVM_ABI bool is_other(const basic_file_status &status)
Does this status represent something that exists but is not a directory or regular file?
LLVM_ABI std::error_code getPotentiallyUniqueTempFileName(const Twine &Prefix, StringRef Suffix, SmallVectorImpl< char > &ResultPath)
Get a unique temporary file name, not currently exisiting in the filesystem.
FileAccess
Definition FileSystem.h:745
@ FA_Read
Definition FileSystem.h:746
@ FA_Write
Definition FileSystem.h:747
perms & operator|=(perms &l, perms r)
Definition FileSystem.h:116
LLVM_ABI Expected< size_t > readNativeFile(file_t FileHandle, MutableArrayRef< char > Buf)
Reads Buf.size() bytes from FileHandle into Buf.
LLVM_ABI unsigned getUmask()
Get file creation mode mask of the process.
LLVM_ABI bool exists(const basic_file_status &status)
Does file exist?
LLVM_ABI Expected< file_t > openNativeFile(const Twine &Name, CreationDisposition Disp, FileAccess Access, OpenFlags Flags, unsigned Mode=0666)
Opens a file with the specified creation disposition, access mode, and flags and returns a platform-s...
OpenFlags
Definition FileSystem.h:750
@ OF_Delete
The returned handle can be used for deleting the file.
Definition FileSystem.h:771
@ OF_ChildInherit
When a child process is launched, this file should remain open in the child process.
Definition FileSystem.h:775
@ OF_Text
The file should be opened in text mode on platforms like z/OS that make this distinction.
Definition FileSystem.h:755
@ OF_None
Definition FileSystem.h:751
@ OF_CRLF
The file should use a carriage linefeed '\r '.
Definition FileSystem.h:759
@ OF_UpdateAtime
Force files Atime to be updated on access.
Definition FileSystem.h:779
@ OF_TextWithCRLF
The file should be opened in text mode and use a carriage linefeed '\r '.
Definition FileSystem.h:764
@ OF_Append
The file should be opened in append mode.
Definition FileSystem.h:767
LLVM_ABI file_t getStdoutHandle()
Return an open handle to standard out.
file_type
An enumeration for the file system's view of the type.
Definition FileSystem.h:62
@ directory_file
Definition FileSystem.h:66
@ status_error
Definition FileSystem.h:63
@ type_unknown
Definition FileSystem.h:72
@ regular_file
Definition FileSystem.h:65
@ fifo_file
Definition FileSystem.h:70
@ file_not_found
Definition FileSystem.h:64
@ character_file
Definition FileSystem.h:69
@ block_file
Definition FileSystem.h:68
@ socket_file
Definition FileSystem.h:71
@ symlink_file
Definition FileSystem.h:67
LLVM_ABI std::error_code create_link(const Twine &to, const Twine &from)
Create a link from from to to.
Expected< file_t > openNativeFileForWrite(const Twine &Name, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
Definition FileSystem.h:1084
LLVM_ABI void expand_tilde(const Twine &path, SmallVectorImpl< char > &output)
Expands ~ expressions to the user's home directory.
LLVM_ABI std::error_code getUniqueID(const Twine Path, UniqueID &Result)
LLVM_ABI std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None, unsigned Mode=all_read|all_write)
Create a uniquely named file.
LLVM_ABI std::error_code lockFile(int FD, LockKind Kind=LockKind::Exclusive)
Lock the file.
LLVM_ABI std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
LLVM_ABI std::error_code set_current_path(const Twine &path)
Set the current path.
int file_t
Definition FileSystem.h:56
LLVM_ABI std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
CreationDisposition
Definition FileSystem.h:723
@ CD_OpenExisting
CD_OpenExisting - When opening a file:
Definition FileSystem.h:737
@ CD_OpenAlways
CD_OpenAlways - When opening a file:
Definition FileSystem.h:742
@ CD_CreateAlways
CD_CreateAlways - When opening a file:
Definition FileSystem.h:727
@ CD_CreateNew
CD_CreateNew - When opening a file:
Definition FileSystem.h:732
LLVM_ABI Expected< size_t > readNativeFileSlice(file_t FileHandle, MutableArrayRef< char > Buf, uint64_t Offset)
Reads Buf.size() bytes from FileHandle at offset Offset into Buf.
LLVM_ABI std::error_code changeFileOwnership(int FD, uint32_t Owner, uint32_t Group)
Change ownership of a file.
Expected< file_t > openNativeFileForReadWrite(const Twine &Name, CreationDisposition Disp, OpenFlags Flags, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
Definition FileSystem.h:1126
LLVM_ABI std::string getMainExecutable(const char *argv0, void *MainExecAddr)
Return the path to the main executable, given the value of argv[0] from program startup and the addre...
LLVM_ABI void createUniquePath(const Twine &Model, SmallVectorImpl< char > &ResultPath, bool MakeAbsolute)
Create a potentially unique file name but does not create it.
std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
Definition FileSystem.h:1065
LLVM_ABI Expected< file_t > openNativeFileForRead(const Twine &Name, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
LLVM_ABI std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
LLVM_ABI bool status_known(const basic_file_status &s)
Is status available?
LLVM_ABI std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
Create a file in the system temporary directory.
AccessMode
Definition FileSystem.h:442
@ Write
Definition FileSystem.h:442
@ Execute
Definition FileSystem.h:442
@ Exist
Definition FileSystem.h:442
LLVM_ABI file_type get_file_type(const Twine &Path, bool Follow=true)
Does status represent a directory?
LLVM_ABI std::error_code make_absolute(SmallVectorImpl< char > &path)
Make path an absolute path.
LLVM_ABI std::error_code resize_file_sparse(int FD, uint64_t Size)
Resize path to size with sparse files explicitly enabled.
LLVM_ABI std::error_code copy_file(const Twine &From, const Twine &To)
Copy the contents of From to To.
LLVM_ABI std::error_code createUniqueDirectory(const Twine &Prefix, SmallVectorImpl< char > &ResultPath)
LLVM_ABI std::error_code tryLockFile(int FD, std::chrono::milliseconds Timeout=std::chrono::milliseconds(0), LockKind Kind=LockKind::Exclusive)
Try to locks the file during the specified time.
LLVM_ABI std::error_code current_path(SmallVectorImpl< char > &result)
Get the current path.
LockKind
An enumeration for the lock kind.
Definition FileSystem.h:1168
@ Exclusive
Definition FileSystem.h:1169
@ Shared
Definition FileSystem.h:1170
perms
Definition FileSystem.h:82
@ all_write
Definition FileSystem.h:97
@ group_read
Definition FileSystem.h:88
@ others_read
Definition FileSystem.h:92
@ owner_all
Definition FileSystem.h:87
@ owner_read
Definition FileSystem.h:84
@ group_exe
Definition FileSystem.h:90
@ all_exe
Definition FileSystem.h:98
@ all_all
Definition FileSystem.h:99
@ set_uid_on_exe
Definition FileSystem.h:100
@ owner_exe
Definition FileSystem.h:86
@ others_write
Definition FileSystem.h:93
@ sticky_bit
Definition FileSystem.h:102
@ no_perms
Definition FileSystem.h:83
@ others_all
Definition FileSystem.h:95
@ group_write
Definition FileSystem.h:89
@ perms_not_known
Definition FileSystem.h:104
@ all_read
Definition FileSystem.h:96
@ group_all
Definition FileSystem.h:91
@ others_exe
Definition FileSystem.h:94
@ set_gid_on_exe
Definition FileSystem.h:101
@ owner_write
Definition FileSystem.h:85
@ all_perms
Definition FileSystem.h:103
LLVM_ABI std::error_code resize_file(int FD, uint64_t Size)
Resize path to size.
LLVM_ABI file_t convertFDToNativeFile(int FD)
Converts from a Posix file descriptor number to a native file handle.
Definition FileSystem.h:991
LLVM_ABI std::error_code status(const Twine &path, file_status &result, bool follow=true)
Get file status as if by POSIX stat().
LLVM_ABI std::error_code create_directory(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create the directory in path.
LLVM_ABI std::error_code is_local(const Twine &path, bool &result)
Is the file mounted on a local filesystem?
LLVM_ABI std::error_code openFileForRead(const Twine &Name, int &ResultFD, OpenFlags Flags=OF_None, SmallVectorImpl< char > *RealPath=nullptr)
Opens the file with the given name in a read-only mode, returning its open file descriptor.
LLVM_ABI std::error_code remove_directories(const Twine &path, bool IgnoreErrors=true)
Recursively delete a directory.
LLVM_ABI bool equivalent(file_status A, file_status B)
Do file_status's represent the same thing?
LLVM_ABI file_t getStderrHandle()
Return an open handle to standard error.
LLVM_ABI std::error_code setLastAccessAndModificationTime(int FD, TimePoint<> AccessTime, TimePoint<> ModificationTime)
Set the file modification and access time.
LLVM_ABI ErrorOr< MD5::MD5Result > md5_contents(int FD)
Compute an MD5 hash of a file's contents.
LLVM_ABI file_t getStdinHandle()
Return an open handle to standard in.
LLVM_ABI std::error_code unlockFile(int FD)
Unlock the file.
std::error_code file_size(const Twine &Path, uint64_t &Result)
Get file size.
Definition FileSystem.h:684
LLVM_ABI std::error_code setPermissions(const Twine &Path, perms Permissions)
Set file permissions.
LLVM_ABI bool is_directory(const basic_file_status &status)
Does status represent a directory?
std::chrono::time_point< std::chrono::system_clock, D > TimePoint
A time point on the system clock.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
@ Timeout
Reached timeout while waiting for the owner to release the lock.
Implement std::hash so that hash_code can be used in STL containers.
Keeps state for the directory_iterator.
Definition FileSystem.h:1428
~DirIterState()
Definition FileSystem.h:1429
directory_entry CurrentEntry
Definition FileSystem.h:1434
intptr_t IterationHandle
Definition FileSystem.h:1433
Keeps state for the recursive_directory_iterator.
Definition FileSystem.h:1494
std::vector< directory_iterator > Stack
Definition FileSystem.h:1495
uint16_t Level
Definition FileSystem.h:1496
bool HasNoPushRequest
Definition FileSystem.h:1497
space_info - Self explanatory.
Definition FileSystem.h:76
uint64_t capacity
Definition FileSystem.h:77
uint64_t free
Definition FileSystem.h:78
uint64_t available
Definition FileSystem.h:79