Skip to content

Commit

Permalink
CDUtils: Namespace code under the Common namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
lioncash committed May 27, 2018
1 parent 5fdf171 commit 1f75fa0
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Source/Core/Common/CDUtils.cpp
Expand Up @@ -34,6 +34,8 @@
#include <linux/cdrom.h> #include <linux/cdrom.h>
#endif #endif


namespace Common
{
#ifdef _WIN32 #ifdef _WIN32
// takes a root drive path, returns true if it is a cdrom drive // takes a root drive path, returns true if it is a cdrom drive
bool is_cdrom(const TCHAR* drive) bool is_cdrom(const TCHAR* drive)
Expand Down Expand Up @@ -219,3 +221,4 @@ bool cdio_is_cdrom(std::string device)
} }
return false; return false;
} }
} // namespace Common
3 changes: 3 additions & 0 deletions Source/Core/Common/CDUtils.h
Expand Up @@ -7,8 +7,11 @@
#include <string> #include <string>
#include <vector> #include <vector>


namespace Common
{
// Returns a pointer to an array of strings with the device names // Returns a pointer to an array of strings with the device names
std::vector<std::string> cdio_get_devices(); std::vector<std::string> cdio_get_devices();


// Returns true if device is cdrom/dvd // Returns true if device is cdrom/dvd
bool cdio_is_cdrom(std::string device); bool cdio_is_cdrom(std::string device);
} // namespace Common
2 changes: 1 addition & 1 deletion Source/Core/Core/Boot/Boot.cpp
Expand Up @@ -62,7 +62,7 @@ std::unique_ptr<BootParameters>
BootParameters::GenerateFromFile(const std::string& path, BootParameters::GenerateFromFile(const std::string& path,
const std::optional<std::string>& savestate_path) const std::optional<std::string>& savestate_path)
{ {
const bool is_drive = cdio_is_cdrom(path); const bool is_drive = Common::cdio_is_cdrom(path);
// Check if the file exist, we may have gotten it from a --elf command line // Check if the file exist, we may have gotten it from a --elf command line
// that gave an incorrect file name // that gave an incorrect file name
if (!is_drive && !File::Exists(path)) if (!is_drive && !File::Exists(path))
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DiscIO/Blob.cpp
Expand Up @@ -176,7 +176,7 @@ u32 SectorReader::ReadChunk(u8* buffer, u64 chunk_num)


std::unique_ptr<BlobReader> CreateBlobReader(const std::string& filename) std::unique_ptr<BlobReader> CreateBlobReader(const std::string& filename)
{ {
if (cdio_is_cdrom(filename)) if (Common::cdio_is_cdrom(filename))
return DriveReader::Create(filename); return DriveReader::Create(filename);


File::IOFile file(filename, "rb"); File::IOFile file(filename, "rb");
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt2/MenuBar.cpp
Expand Up @@ -166,7 +166,7 @@ void MenuBar::AddDVDBackupMenu(QMenu* file_menu)
{ {
m_backup_menu = file_menu->addMenu(tr("&Boot from DVD Backup")); m_backup_menu = file_menu->addMenu(tr("&Boot from DVD Backup"));


const std::vector<std::string> drives = cdio_get_devices(); const std::vector<std::string> drives = Common::cdio_get_devices();
// Windows Limitation of 24 character drives // Windows Limitation of 24 character drives
for (size_t i = 0; i < drives.size() && i < 24; i++) for (size_t i = 0; i < drives.size() && i < 24; i++)
{ {
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/GameListCtrl.cpp
Expand Up @@ -397,7 +397,7 @@ void GameListCtrl::RefreshList()
if (SConfig::GetInstance().m_ListDrives) if (SConfig::GetInstance().m_ListDrives)
{ {
std::unique_lock<std::mutex> lk(m_title_database_mutex); std::unique_lock<std::mutex> lk(m_title_database_mutex);
for (const auto& drive : cdio_get_devices()) for (const auto& drive : Common::cdio_get_devices())
{ {
auto file = std::make_shared<UICommon::GameFile>(drive); auto file = std::make_shared<UICommon::GameFile>(drive);
if (file->IsValid()) if (file->IsValid())
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/MainMenuBar.cpp
Expand Up @@ -72,7 +72,7 @@ wxMenu* MainMenuBar::CreateFileMenu() const
{ {
auto* const external_drive_menu = new wxMenu; auto* const external_drive_menu = new wxMenu;


const std::vector<std::string> drives = cdio_get_devices(); const std::vector<std::string> drives = Common::cdio_get_devices();
// Windows Limitation of 24 character drives // Windows Limitation of 24 character drives
for (size_t i = 0; i < drives.size() && i < 24; i++) for (size_t i = 0; i < drives.size() && i < 24; i++)
{ {
Expand Down

0 comments on commit 1f75fa0

Please sign in to comment.