mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibCore: Convert File to east-const style
This commit is contained in:
parent
068802d58d
commit
3cc0283eac
2 changed files with 24 additions and 24 deletions
|
@ -106,7 +106,7 @@ bool File::is_device() const
|
|||
return S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_device(const String& filename)
|
||||
bool File::is_device(String const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -122,7 +122,7 @@ bool File::is_directory() const
|
|||
return S_ISDIR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_directory(const String& filename)
|
||||
bool File::is_directory(String const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -138,7 +138,7 @@ bool File::is_link() const
|
|||
return S_ISLNK(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_link(const String& filename)
|
||||
bool File::is_link(String const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (lstat(filename.characters(), &st) < 0)
|
||||
|
@ -146,13 +146,13 @@ bool File::is_link(const String& filename)
|
|||
return S_ISLNK(st.st_mode);
|
||||
}
|
||||
|
||||
bool File::exists(const String& filename)
|
||||
bool File::exists(String const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
return stat(filename.characters(), &st) == 0;
|
||||
}
|
||||
|
||||
String File::real_path_for(const String& filename)
|
||||
String File::real_path_for(String const& filename)
|
||||
{
|
||||
if (filename.is_null())
|
||||
return {};
|
||||
|
@ -162,7 +162,7 @@ String File::real_path_for(const String& filename)
|
|||
return real_path;
|
||||
}
|
||||
|
||||
bool File::ensure_parent_directories(const String& path)
|
||||
bool File::ensure_parent_directories(String const& path)
|
||||
{
|
||||
VERIFY(path.starts_with("/"));
|
||||
|
||||
|
@ -172,7 +172,7 @@ bool File::ensure_parent_directories(const String& path)
|
|||
char* parent_buffer = strdup(path.characters());
|
||||
ScopeGuard free_buffer = [parent_buffer] { free(parent_buffer); };
|
||||
|
||||
const char* parent = dirname(parent_buffer);
|
||||
char const* parent = dirname(parent_buffer);
|
||||
|
||||
int rc = mkdir(parent, 0755);
|
||||
saved_errno = errno;
|
||||
|
@ -313,7 +313,7 @@ NonnullRefPtr<File> File::standard_error()
|
|||
return *stderr_file;
|
||||
}
|
||||
|
||||
static String get_duplicate_name(const String& path, int duplicate_count)
|
||||
static String get_duplicate_name(String const& path, int duplicate_count)
|
||||
{
|
||||
if (duplicate_count == 0) {
|
||||
return path;
|
||||
|
@ -338,7 +338,7 @@ static String get_duplicate_name(const String& path, int duplicate_count)
|
|||
return duplicated_name.build();
|
||||
}
|
||||
|
||||
Result<void, File::CopyError> File::copy_file_or_directory(const String& dst_path, const String& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker)
|
||||
Result<void, File::CopyError> File::copy_file_or_directory(String const& dst_path, String const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker)
|
||||
{
|
||||
if (add_duplicate_file_marker == AddDuplicateFileMarker::Yes) {
|
||||
int duplicate_count = 0;
|
||||
|
@ -376,7 +376,7 @@ Result<void, File::CopyError> File::copy_file_or_directory(const String& dst_pat
|
|||
return copy_file(dst_path, src_stat, source);
|
||||
}
|
||||
|
||||
Result<void, File::CopyError> File::copy_file(const String& dst_path, const struct stat& src_stat, File& source)
|
||||
Result<void, File::CopyError> File::copy_file(String const& dst_path, struct stat const& src_stat, File& source)
|
||||
{
|
||||
int dst_fd = creat(dst_path.characters(), 0666);
|
||||
if (dst_fd < 0) {
|
||||
|
@ -426,7 +426,7 @@ Result<void, File::CopyError> File::copy_file(const String& dst_path, const stru
|
|||
return {};
|
||||
}
|
||||
|
||||
Result<void, File::CopyError> File::copy_directory(const String& dst_path, const String& src_path, const struct stat& src_stat, LinkMode link)
|
||||
Result<void, File::CopyError> File::copy_directory(String const& dst_path, String const& src_path, struct stat const& src_stat, LinkMode link)
|
||||
{
|
||||
if (mkdir(dst_path.characters(), 0755) < 0)
|
||||
return CopyError { OSError(errno), false };
|
||||
|
@ -461,7 +461,7 @@ Result<void, File::CopyError> File::copy_directory(const String& dst_path, const
|
|||
return {};
|
||||
}
|
||||
|
||||
Result<void, OSError> File::link_file(const String& dst_path, const String& src_path)
|
||||
Result<void, OSError> File::link_file(String const& dst_path, String const& src_path)
|
||||
{
|
||||
int duplicate_count = 0;
|
||||
while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) {
|
||||
|
@ -478,7 +478,7 @@ Result<void, OSError> File::link_file(const String& dst_path, const String& src_
|
|||
return {};
|
||||
}
|
||||
|
||||
Result<void, File::RemoveError> File::remove(const String& path, RecursionMode mode, bool force)
|
||||
Result<void, File::RemoveError> File::remove(String const& path, RecursionMode mode, bool force)
|
||||
{
|
||||
struct stat path_stat;
|
||||
if (lstat(path.characters(), &path_stat) < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue