summaryrefslogtreecommitdiff
path: root/drivers/windows
diff options
context:
space:
mode:
authorNathan Franke <natfra@pm.me>2021-12-09 03:42:46 -0600
committerNathan Franke <natfra@pm.me>2021-12-09 04:48:38 -0600
commit49403cbfa0399bb4284ea5c36cc90216a0bda6ff (patch)
treecaa6c7249d35d83b288a180a4f5d7e4fd959704f /drivers/windows
parent31ded7e126b9d71ed8dddab9ffc1ce813f1a8ec2 (diff)
Replace String comparisons with "", String() to is_empty()
Also: - Adds two stress tests to test_string.h - Changes to .empty() on std::strings
Diffstat (limited to 'drivers/windows')
-rw-r--r--drivers/windows/dir_access_windows.cpp6
-rw-r--r--drivers/windows/file_access_windows.cpp4
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp
index 3e98e36d14..aa8d7977f7 100644
--- a/drivers/windows/dir_access_windows.cpp
+++ b/drivers/windows/dir_access_windows.cpp
@@ -133,7 +133,7 @@ Error DirAccessWindows::change_dir(String p_dir) {
bool worked = (SetCurrentDirectoryW((LPCWSTR)(p_dir.utf16().get_data())) != 0);
String base = _get_root_path();
- if (base != "") {
+ if (!base.is_empty()) {
GetCurrentDirectoryW(2048, real_current_dir_name);
String new_dir = String::utf16((const char16_t *)real_current_dir_name).replace("\\", "/");
if (!new_dir.begins_with(base)) {
@@ -184,7 +184,7 @@ Error DirAccessWindows::make_dir(String p_dir) {
String DirAccessWindows::get_current_dir(bool p_include_drive) {
String base = _get_root_path();
- if (base != "") {
+ if (!base.is_empty()) {
String bd = current_dir.replace("\\", "/").replace_first(base, "");
if (bd.begins_with("/")) {
return _get_root_string() + bd.substr(1, bd.length());
@@ -196,7 +196,7 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) {
if (p_include_drive) {
return current_dir;
} else {
- if (_get_root_string() == "") {
+ if (_get_root_string().is_empty()) {
int p = current_dir.find(":");
if (p != -1) {
return current_dir.substr(p + 1);
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index ff81622408..2c7b5b9be9 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -99,7 +99,7 @@ Error FileAccessWindows::_open(const String &p_path, int p_mode_flags) {
HANDLE f = FindFirstFileW((LPCWSTR)(path.utf16().get_data()), &d);
if (f != INVALID_HANDLE_VALUE) {
String fname = String::utf16((const char16_t *)(d.cFileName));
- if (fname != String()) {
+ if (!fname.is_empty()) {
String base_file = path.get_file();
if (base_file != fname && base_file.findn(fname) == 0) {
WARN_PRINT("Case mismatch opening requested file '" + base_file + "', stored as '" + fname + "' in the filesystem. This file will not open when exported to other case-sensitive platforms.");
@@ -142,7 +142,7 @@ void FileAccessWindows::close() {
fclose(f);
f = nullptr;
- if (save_path != "") {
+ if (!save_path.is_empty()) {
bool rename_error = true;
int attempts = 4;
while (rename_error && attempts) {