]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Host/FileSystem.h
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / 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 <stdint.h>
14 #include <stdio.h>
15 #include <sys/stat.h>
16
17 #include "lldb/lldb-types.h"
18
19 #include "lldb/Core/Error.h"
20 #include "lldb/Host/FileSpec.h"
21
22 namespace lldb_private
23 {
24 class FileSystem
25 {
26   public:
27     static const char *DEV_NULL;
28     static const char *PATH_CONVERSION_ERROR;
29
30     static FileSpec::PathSyntax GetNativePathSyntax();
31
32     static Error MakeDirectory(const FileSpec &file_spec, uint32_t mode);
33     static Error DeleteDirectory(const FileSpec &file_spec, bool recurse);
34
35     static Error GetFilePermissions(const FileSpec &file_spec,
36                                     uint32_t &file_permissions);
37     static Error SetFilePermissions(const FileSpec &file_spec,
38                                     uint32_t file_permissions);
39     static lldb::user_id_t GetFileSize(const FileSpec &file_spec);
40     static bool GetFileExists(const FileSpec &file_spec);
41
42     static Error Hardlink(const FileSpec &src, const FileSpec &dst);
43     static int GetHardlinkCount(const FileSpec &file_spec);
44     static Error Symlink(const FileSpec &src, const FileSpec &dst);
45     static Error Readlink(const FileSpec &src, FileSpec &dst);
46     static Error Unlink(const FileSpec &file_spec);
47     
48     static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
49
50     static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high);
51     static bool CalculateMD5(const FileSpec &file_spec,
52                              uint64_t offset,
53                              uint64_t length,
54                              uint64_t &low,
55                              uint64_t &high);
56
57     static bool CalculateMD5AsString(const FileSpec &file_spec, std::string& digest_str);
58     static bool CalculateMD5AsString(const FileSpec &file_spec,
59                                      uint64_t offset,
60                                      uint64_t length,
61                                      std::string& digest_str);
62
63     /// Return \b true if \a spec is on a locally mounted file system, \b false otherwise.
64     static bool IsLocal(const FileSpec &spec);
65
66     /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be
67     /// manipulated and closed with the normal ::fread, ::fclose, etc. functions.
68     static FILE *
69     Fopen(const char *path, const char *mode);
70
71     /// Wraps ::stat in a platform-independent way.
72     static int
73     Stat(const char *path, struct stat *stats);
74 };
75 }
76
77 #endif