Skip to content

Commit

Permalink
tweak: somewhat complete string imp
Browse files Browse the repository at this point in the history
  • Loading branch information
Force67 committed May 1, 2024
1 parent 87ba459 commit 41a6c8f
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 83 deletions.
5 changes: 3 additions & 2 deletions base/command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ void CommandLine::ParseFromString(const base::StringRefU8 command_line) {
void CommandLine::FromArray(int count, char** args) {
for (int i = 0; i < count; i++) {
char* arg = args[i];
pieces_.push_back(reinterpret_cast<char8_t*>(arg));
const base::StringU8 arg_str(reinterpret_cast<char8_t*>(arg));
pieces_.push_back(arg_str);
}
}

bool CommandLine::HasItem(const base::StringRefU8 switch_name) {
return pieces_.Contains(switch_name.c_str());
return pieces_.Contains(base::StringU8(switch_name.c_str()));
}

i32 CommandLine::FindSwitchIndex(const base::StringRefU8 switch_name) {
Expand Down
2 changes: 1 addition & 1 deletion base/filesystem/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BASE_EXPORT Path {
// The character used to identify a file extension.
static constexpr CharType kExtensionSeparator = BASE_PATH_LITERAL('.');

using BufferType = base::BasicString<CharType>;
using BufferType = base::XBasicString<CharType>;

Path() = default;

Expand Down
6 changes: 4 additions & 2 deletions base/filesystem/scoped_temp_dir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ bool ScopedTempDir::CreateUniqueTempDir() {

// This "scoped_dir" prefix is only used on Windows and serves as a template
// for the unique name.
if (!CreateNewTempDirectory(kScopedDirPrefix, &path_))
const Path::BufferType prefix(kScopedDirPrefix);
if (!CreateNewTempDirectory(prefix, &path_))
return false;

return true;
Expand All @@ -43,7 +44,8 @@ bool ScopedTempDir::CreateUniqueTempDirUnderPath(const Path& base_path) {
return false;

// Create a new, uniquely named directory under |base_path|.
if (!CreateTemporaryDirInDir(base_path, kScopedDirPrefix, &path_))
const Path::BufferType prefix(kScopedDirPrefix);
if (!CreateTemporaryDirInDir(base_path, prefix, &path_))
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions base/filesystem/win/file_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ DWORD DoDeleteFile(const Path& path, bool recursive) {
return ::DeleteFile(path.c_str()) ? ERROR_SUCCESS
: ReturnLastErrorOrSuccessOnNotFound();
}

const Path::BufferType pattern(BASE_PATH_LITERAL("*"));
if (recursive) {
const DWORD error_code = DeleteFileRecursive(path, BASE_PATH_LITERAL("*"), true);
const DWORD error_code = DeleteFileRecursive(path, pattern, true);
DCHECK(static_cast<LONG>(error_code) != ERROR_FILE_NOT_FOUND);
DCHECK(static_cast<LONG>(error_code) != ERROR_PATH_NOT_FOUND);
if (error_code != ERROR_SUCCESS)
Expand Down
Loading

0 comments on commit 41a6c8f

Please sign in to comment.