Added cdutils which suppose to scan for devices in a portable way (ripped from cdio)

Changed the Code to use it instead of DriveUtil code.
Please test the code


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2413 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee
2009-02-24 15:04:12 +00:00
parent e79a93f616
commit 9b1f0f9083
9 changed files with 14 additions and 122 deletions

View File

@ -1,46 +0,0 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <string>
#include "DriveUtil.h"
#ifdef _WIN32
#include <windows.h>
#include <winioctl.h>
#elif defined(__GNUC__) // TODO: replace these with real linux / os x functinos
#define GetLogicalDriveStrings(x, y) (int)memcpy(y,"/dev/cdrom\0/dev/cdrom1\0/dev/cdrom2\0/dev/cdrom3\0/dev/cdrom4\0/dev/cdrom5\0/dev/cdrom6\0/dev/cdrom7\0/dev/cdrom8\0/dev/cdrom9\0\0\0", 121);
#else
#define GetLogicalDriveStrings(x, y) (int)memcpy(y,"/dev/disk2\0/dev/disk3\0/dev/disk4\0/dev/disk5\0/dev/disk6\0/dev/disk7\0/dev/disk8\0/dev/disk9\0/dev/disk10\0/dev/disk11\0\0\0",114);
#endif
void GetAllRemovableDrives(std::vector<std::string> *drives) {
drives->clear();
char drives_string[1024];
int max_drive_pos = GetLogicalDriveStrings(1024, drives_string);
char *p = drives_string;
// GetLogicalDriveStrings returns the drives as a a series of null-terminated strings
// laid out right after each other in RAM, with a double null at the end.
while (*p)
{
if (File::IsDisk(p))
{
drives->push_back(std::string(p));
}
p += strlen(p) + 1;
}
}

View File

@ -1,30 +0,0 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _DRIVEUTIL_H
#define _DRIVEUTIL_H
#include <string>
#include <vector>
#include "Common.h"
#include "FileUtil.h"
// Tools to enumerate drives (HDD, DVD, CD) in a platform-independent manner.
void GetAllRemovableDrives(std::vector<std::string> *drives);
#endif

View File

@ -72,40 +72,6 @@ bool Exists(const char *filename)
return (result == 0);
}
bool IsDisk(const char *filename)
{
#ifdef _WIN32
if (GetDriveType(filename) == DRIVE_CDROM) // CD_ROM also applies to DVD. Noone has a plain CDROM without DVD anymore so we should be fine.
return true;
#else
struct stat statInfo;
if((stat(filename, &statInfo) > -1) && (S_ISCHR(statInfo.st_mode) || S_ISBLK(statInfo.st_mode)))
{
int fileHandle;
// try to open the device
fileHandle = open(filename, O_RDONLY | O_NONBLOCK, 0);
if (fileHandle >= 0)
{
cdrom_subchnl cdChannelInfo;
cdChannelInfo.cdsc_format = CDROM_MSF;
if ((ioctl(fileHandle, CDROMSUBCHNL, &cdChannelInfo) == 0) ||
(errno == EIO) || (errno == ENOENT) ||
(errno == EINVAL)
#ifdef __GNUC__
|| (errno == ENOMEDIUM)
#endif
)
{
return true;
}
close(fileHandle);
}
}
#endif
return false;
}
bool IsDirectory(const char *filename)
{
struct stat file_info;

View File

@ -5,11 +5,11 @@ Import('env')
files = [
"ABI.cpp",
"MsgHandler.cpp",
"CDUtils.cpp",
"ChunkFile.cpp",
"ConsoleWindow.cpp",
"ColorUtil.cpp",
"CPUDetect.cpp",
"DriveUtil.cpp",
"DynamicLibrary.cpp",
"Hash.cpp",
"IniFile.cpp",