summaryrefslogtreecommitdiff
path: root/src/lib/cross_windows.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-23 21:53:32 +0100
committerCarl Hetherington <cth@carlh.net>2024-12-26 00:27:08 +0100
commit8caf013a9b8d709ed7c3d5e9febee0067e6fcf1f (patch)
tree40da87cb357e8b1c54a1464bdbac2d014640e30c /src/lib/cross_windows.cc
parentcec6ff92aef45c687085ecfc1059004407c18c57 (diff)
Replace String::compose with fmt::format().
Diffstat (limited to 'src/lib/cross_windows.cc')
-rw-r--r--src/lib/cross_windows.cc33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/lib/cross_windows.cc b/src/lib/cross_windows.cc
index 56ff73ec9..d4b8fe461 100644
--- a/src/lib/cross_windows.cc
+++ b/src/lib/cross_windows.cc
@@ -22,7 +22,6 @@
#define UNICODE 1
#include "cross.h"
-#include "compose.hpp"
#include "log.h"
#include "dcpomatic_log.h"
#include "config.h"
@@ -404,7 +403,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
auto r = SetupDiEnumDeviceInterfaces (device_info, device_info_data, &GUID_DEVICE_INTERFACE_DISK, 0, &device_interface_data);
if (!r) {
- LOG_DISK("SetupDiEnumDeviceInterfaces failed (%1)", GetLastError());
+ LOG_DISK("SetupDiEnumDeviceInterfaces failed ({})", GetLastError());
return optional<int>();
}
@@ -439,7 +438,7 @@ get_device_number (HDEVINFO device_info, SP_DEVINFO_DATA* device_info_data)
free (device_detail_data);
if (device == INVALID_HANDLE_VALUE) {
- LOG_DISK("CreateFileW failed with %1", GetLastError());
+ LOG_DISK("CreateFileW failed with {}", GetLastError());
return optional<int>();
}
@@ -469,7 +468,7 @@ typedef map<int, vector<boost::filesystem::path>> MountPoints;
static void
add_volume_mount_points (wchar_t* volume, MountPoints& mount_points)
{
- LOG_DISK("Looking at %1", wchar_to_utf8(volume));
+ LOG_DISK("Looking at {}", wchar_to_utf8(volume));
wchar_t volume_path_names[512];
vector<boost::filesystem::path> mp;
@@ -478,7 +477,7 @@ add_volume_mount_points (wchar_t* volume, MountPoints& mount_points)
wchar_t* p = volume_path_names;
while (*p != L'\0') {
mp.push_back (wchar_to_utf8(p));
- LOG_DISK ("Found mount point %1", wchar_to_utf8(p));
+ LOG_DISK ("Found mount point {}", wchar_to_utf8(p));
p += wcslen(p) + 1;
}
}
@@ -555,7 +554,7 @@ Drive::get ()
if (!SetupDiEnumDeviceInfo(device_info, i, &device_info_data)) {
DWORD e = GetLastError();
if (e != ERROR_NO_MORE_ITEMS) {
- LOG_DISK ("SetupDiEnumDeviceInfo failed (%1)", GetLastError());
+ LOG_DISK ("SetupDiEnumDeviceInfo failed ({})", GetLastError());
}
break;
}
@@ -567,7 +566,7 @@ Drive::get ()
continue;
}
- string const physical_drive = String::compose("\\\\.\\PHYSICALDRIVE%1", *device_number);
+ string const physical_drive = fmt::format("\\\\.\\PHYSICALDRIVE{}", *device_number);
HANDLE device = CreateFileA (
physical_drive.c_str(), 0,
@@ -587,7 +586,7 @@ Drive::get ()
&geom, sizeof(geom), &returned, 0
);
- LOG_DISK("Having a look through %1 locked volumes", locked_volumes.size());
+ LOG_DISK("Having a look through {} locked volumes", locked_volumes.size());
bool locked = false;
for (auto const& i: locked_volumes) {
if (i.second == physical_drive) {
@@ -598,7 +597,7 @@ Drive::get ()
if (r) {
uint64_t const disk_size = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector;
drives.push_back (Drive(physical_drive, locked ? vector<boost::filesystem::path>() : mount_points[*device_number], disk_size, friendly_name, optional<string>()));
- LOG_DISK("Added drive %1%2", drives.back().log_summary(), locked ? "(locked by us)" : "");
+ LOG_DISK("Added drive {}{}", drives.back().log_summary(), locked ? "(locked by us)" : "");
}
CloseHandle (device);
@@ -611,24 +610,24 @@ Drive::get ()
bool
Drive::unmount ()
{
- LOG_DISK("Unmounting %1 with %2 mount points", _device, _mount_points.size());
+ LOG_DISK("Unmounting {} with {} mount points", _device, _mount_points.size());
DCPOMATIC_ASSERT (_mount_points.size() == 1);
- string const device_name = String::compose ("\\\\.\\%1", _mount_points.front());
- string const truncated = device_name.substr (0, device_name.length() - 1);
- LOG_DISK("Actually opening %1", truncated);
+ auto const device_name = fmt::format("\\\\.\\{}", _mount_points.front());
+ auto const truncated = device_name.substr(0, device_name.length() - 1);
+ LOG_DISK("Actually opening {}", truncated);
HANDLE device = CreateFileA (truncated.c_str(), (GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (device == INVALID_HANDLE_VALUE) {
- LOG_DISK("Could not open %1 for unmount (%2)", truncated, GetLastError());
+ LOG_DISK("Could not open {} for unmount ({})", truncated, GetLastError());
return false;
}
DWORD returned;
BOOL r = DeviceIoControl (device, FSCTL_LOCK_VOLUME, 0, 0, 0, 0, &returned, 0);
if (!r) {
- LOG_DISK("Unmount of %1 failed (%2)", truncated, GetLastError());
+ LOG_DISK("Unmount of {} failed ({})", truncated, GetLastError());
return false;
}
- LOG_DISK("Unmount of %1 succeeded", _device);
+ LOG_DISK("Unmount of {} succeeded", _device);
locked_volumes.push_back (make_pair(device, _device));
return true;
@@ -660,7 +659,7 @@ disk_write_finished ()
string
dcpomatic::get_process_id ()
{
- return dcp::fmt::to_string(GetCurrentProcessId());
+ return fmt::to_string(GetCurrentProcessId());
}