]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Host/FileSystem.h
Merge ^/head r311692 through r311807.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Host / FileSystem.h
1 //===-- FileSystem.h --------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_Host_FileSystem_h
11 #define liblldb_Host_FileSystem_h
12
13 #include "lldb/Core/Error.h"
14 #include "lldb/Host/FileSpec.h"
15 #include "llvm/Support/Chrono.h"
16
17 #include "lldb/lldb-types.h"
18
19 #include <stdint.h>
20 #include <stdio.h>
21 #include <sys/stat.h>
22
23 namespace lldb_private {
24 class FileSystem {
25 public:
26   static const char *DEV_NULL;
27   static const char *PATH_CONVERSION_ERROR;
28
29   static FileSpec::PathSyntax GetNativePathSyntax();
30
31   static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
32   static Error DeleteDirectory(const FileSpec &file_spec, bool recurse);
33
34   static Error GetFilePermissions(const FileSpec &file_spec,
35                                   uint32_t &file_permissions);
36   static Error SetFilePermissions(const FileSpec &file_spec,
37                                   uint32_t file_permissions);
38   static lldb::user_id_t GetFileSize(const FileSpec &file_spec);
39   static bool GetFileExists(const FileSpec &file_spec);
40
41   static Error Hardlink(const FileSpec &src, const FileSpec &dst);
42   static int GetHardlinkCount(const FileSpec &file_spec);
43   static Error Symlink(const FileSpec &src, const FileSpec &dst);
44   static Error Readlink(const FileSpec &src, FileSpec &dst);
45   static Error Unlink(const FileSpec &file_spec);
46
47   static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
48
49   static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
50                            uint64_t &high);
51   static bool CalculateMD5(const FileSpec &file_spec, uint64_t offset,
52                            uint64_t length, uint64_t &low, uint64_t &high);
53
54   static bool CalculateMD5AsString(const FileSpec &file_spec,
55                                    std::string &digest_str);
56   static bool CalculateMD5AsString(const FileSpec &file_spec, uint64_t offset,
57                                    uint64_t length, std::string &digest_str);
58
59   /// Return \b true if \a spec is on a locally mounted file system, \b false
60   /// otherwise.
61   static bool IsLocal(const FileSpec &spec);
62
63   /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be
64   /// manipulated and closed with the normal ::fread, ::fclose, etc. functions.
65   static FILE *Fopen(const char *path, const char *mode);
66
67   /// Wraps ::stat in a platform-independent way.
68   static int Stat(const char *path, struct stat *stats);
69
70   static llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec);
71 };
72 }
73
74 #endif