本文整理汇总了C++中common::File::exists方法的典型用法代码示例。如果您正苦于以下问题:C++ File::exists方法的具体用法?C++ File::exists怎么用?C++ File::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::File
的用法示例。
在下文中一共展示了File::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: play
uint SoundChannel::play(uint soundNum, uint repeats, uint notify) {
stop();
if (repeats == 0)
return 1;
// Find a sound of the given name
Audio::AudioStream *stream;
Common::File f;
Common::String nameSnd = Common::String::format("sound%u.snd", soundNum);
Common::String nameWav = Common::String::format("sound%u.wav", soundNum);
Common::String nameAiff = Common::String::format("sound%u.aiff", soundNum);
#ifdef USE_MAD
Common::String nameMp3 = Common::String::format("sound%u.mp3", soundNum);
#endif
if (f.exists(nameSnd) && f.open(nameSnd)) {
if (f.readUint16BE() != (f.size() - 2))
error("Invalid sound filesize");
repeats = f.readByte();
f.skip(1);
uint freq = f.readUint16BE();
f.skip(2);
uint size = f.readUint16BE();
Common::SeekableReadStream *s = f.readStream(size);
stream = Audio::makeRawStream(s, freq, Audio::FLAG_UNSIGNED);
#ifdef USE_MAD
} else if (f.exists(nameMp3) && f.open(nameMp3)) {
Common::SeekableReadStream *s = f.readStream(f.size());
stream = Audio::makeMP3Stream(s, DisposeAfterUse::YES);
#endif
} else if (f.exists(nameWav) && f.open(nameWav)) {
Common::SeekableReadStream *s = f.readStream(f.size());
stream = Audio::makeWAVStream(s, DisposeAfterUse::YES);
} else if (f.exists(nameAiff) && f.open(nameAiff)) {
Common::SeekableReadStream *s = f.readStream(f.size());
stream = Audio::makeAIFFStream(s, DisposeAfterUse::YES);
} else {
warning("Could not find sound %u", soundNum);
return 1;
}
_soundNum = soundNum;
_notify = notify;
// Set up a repeat if multiple repeats are specified
if (repeats > 1) {
Audio::RewindableAudioStream *rwStream = dynamic_cast<Audio::RewindableAudioStream *>(stream);
assert(rwStream);
stream = new Audio::LoopingAudioStream(rwStream, repeats, DisposeAfterUse::YES);
}
// Start playing the audio
g_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream);
return 0;
}
示例2: playSpeech
void Sound::playSpeech(const Common::String &name) {
Resources &res = *_vm->_res;
Scene &scene = *_vm->_scene;
stopSpeech();
// TODO: Technically Scalpel has an sfx command which I've set to call this method because it sets the
// _voice variable as if it were speech. Need to do a play-through of Scalpel and see if it's ever called.
// If so, will need to enhance this method to handle the Serrated Scalpel voice resources
assert(IS_ROSE_TATTOO);
// Figure out which speech library to use
Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
if ((!scumm_strnicmp(name.c_str(), "SLVE12S", 7)) || (!scumm_strnicmp(name.c_str(), "WATS12X", 7))
|| (!scumm_strnicmp(name.c_str(), "HOLM12X", 7)))
libraryName = "SPEECH12.LIB";
// If the speech library file doesn't even exist, then we can't play anything
Common::File f;
if (!f.exists(libraryName))
return;
// Ensure the given library is in the cache
res.addToCache(libraryName);
if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
_speechPlaying = true;
}
示例3: showCDLogo
bool TeenAgentEngine::showCDLogo() {
Common::File cdlogo;
if (!cdlogo.exists("cdlogo.res") || !cdlogo.open("cdlogo.res"))
return true;
byte bg[0xfa00];
byte palette[3*256];
cdlogo.read(bg, sizeof(bg));
cdlogo.read(palette, sizeof(palette));
for (uint c = 0; c < 3*256; ++c)
palette[c] *= 4;
_system->getPaletteManager()->setPalette(palette, 0, 0x100);
_system->copyRectToScreen(bg, 320, 0, 0, 320, 200);
_system->updateScreen();
for(uint i = 0; i < 20; ++i) {
int r = skipEvents();
if (r != 0)
return r > 0? true: false;
_system->delayMillis(100);
}
cdlogo.close();
return true;
}
示例4: showCDLogo
bool TeenAgentEngine::showCDLogo() {
Common::File cdlogo;
if (!cdlogo.exists("cdlogo.res") || !cdlogo.open("cdlogo.res"))
return true;
byte bg[0xfa00];
byte palette[0x400];
cdlogo.read(bg, sizeof(bg));
memset(palette, 0, sizeof(palette));
for(uint c = 0; c < 0x100; ++c) {
uint idx = c * 4;
cdlogo.read(palette + idx, 3);
palette[idx] *= 4;
palette[idx + 1] *= 4;
palette[idx + 2] *= 4;
}
_system->setPalette(palette, 0, 0x100);
_system->copyRectToScreen(bg, 320, 0, 0, 320, 200);
_system->updateScreen();
for(uint i = 0; i < 20; ++i) {
int r = skipEvents();
if (r != 0)
return r > 0? true: false;
_system->delayMillis(100);
}
cdlogo.close();
return true;
}
示例5: fileExists
bool FileSystemUtil::fileExists(const Common::String &filename) {
Common::File f;
if (f.exists(filename))
return true;
// Check if the file exists in the save folder
Common::FSNode folder(PersistenceService::getSavegameDirectory());
Common::FSNode fileNode = folder.getChild(getPathFilename(filename));
return fileNode.exists();
}
示例6: Cmd_PlayText
bool Debugger::Cmd_PlayText(int argc, const char **argv) {
if (argc != 2) {
debugPrintf("Usage: %s <text name>\n", argv[0]);
return true;
} else {
Common::String resName = argv[1];
if (resName.hasPrefix("@"))
resName.deleteChar(0);
Common::File f;
if (f.exists(resName) || f.exists(resName + ".txr")) {
TextView::execute(_vm, resName);
return false;
} else {
debugPrintf("Could not find resource file\n");
return true;
}
}
}
示例7: loadAnim
/**
* Load Animation
*/
void AnimationManager::loadAnim(const Common::String &animName) {
clearAnim();
Common::String filename = animName + ".ANI";
Common::File f;
if (!f.open(filename))
error("Failed to open %s", filename.c_str());
int filesize = f.size();
int nbytes = filesize - 115;
char header[10];
char dummyBuf[15];
char filename1[15];
char filename2[15];
char filename3[15];
char filename4[15];
char filename5[15];
char filename6[15];
f.read(header, 10);
f.read(dummyBuf, 15);
f.read(filename1, 15);
f.read(filename2, 15);
f.read(filename3, 15);
f.read(filename4, 15);
f.read(filename5, 15);
f.read(filename6, 15);
if (READ_BE_UINT32(header) != MKTAG('A', 'N', 'I', 'S'))
error("Invalid animation File: %s", filename.c_str());
const char *files[6] = { &filename1[0], &filename2[0], &filename3[0], &filename4[0],
&filename5[0], &filename6[0] };
for (int idx = 0; idx <= 5; ++idx) {
if (files[idx][0]) {
if (!f.exists(files[idx]))
error("Missing file %s in animation File: %s", files[idx], filename.c_str());
if (loadSpriteBank(idx + 1, files[idx]))
error("Invalid sprite bank in animation File: %s", filename.c_str());
}
}
byte *data = _vm->_globals->allocMemory(nbytes + 1);
f.read(data, nbytes);
f.close();
for (int idx = 1; idx <= 20; ++idx)
searchAnim(data, idx, nbytes);
_vm->_globals->freeMemory(data);
}
示例8: exists
CString CResourceKey::exists() const {
CString name = _key;
// Check for a resource being specified within an ST container
int idx = name.indexOf('#');
if (idx >= 0) {
name = name.left(idx);
name += ".st";
}
// The original did tests for the file in the different
// asset paths, which aren't needed in ScummVM
Common::File f;
return f.exists(name) ? name : CString();
}
示例9: initialize
void SherlockEngine::initialize() {
DebugMan.addDebugChannel(kDebugLevelScript, "scripts", "Script debug level");
DebugMan.addDebugChannel(kDebugLevelAdLibDriver, "AdLib", "AdLib driver debugging");
DebugMan.addDebugChannel(kDebugLevelMT32Driver, "MT32", "MT32 driver debugging");
DebugMan.addDebugChannel(kDebugLevelMusic, "Music", "Music debugging");
Fonts::setVm(this);
ImageFile::setVm(this);
ImageFile3DO::setVm(this);
BaseObject::setVm(this);
if (isDemo()) {
Common::File f;
// The interactive demo doesn't have an intro thus doesn't include TITLE.SND
// At the opposite, the non-interactive demo is only the intro.
if (f.exists("TITLE.SND"))
_interactiveFl = false;
}
_res = new Resources(this);
_animation = new Animation(this);
_debugger = Debugger::init(this);
_events = new Events(this);
_fixedText = FixedText::init(this);
_inventory = Inventory::init(this);
_map = Map::init(this);
_music = new Music(this, _mixer);
_journal = Journal::init(this);
_people = People::init(this);
_saves = SaveManager::init(this, _targetName);
_scene = Scene::init(this);
_screen = Screen::init(this);
_sound = new Sound(this, _mixer);
_talk = Talk::init(this);
_ui = UserInterface::init(this);
// Load game settings
loadConfig();
if (getPlatform() == Common::kPlatform3DO) {
// Disable portraits on 3DO
// 3DO does not include portrait data
_people->_portraitsOn = false;
}
}
示例10: CCArchive
FileManager::FileManager(XeenEngine *vm) {
Common::File f;
int sideNum = 0;
File::_currentArchive = ANY_ARCHIVE;
_isDarkCc = vm->getGameID() == GType_DarkSide;
_archives[0] = _archives[1] = _archives[2] = nullptr;
if (vm->getGameID() != GType_DarkSide) {
_archives[0] = new CCArchive("xeen.cc", "xeen", true);
SearchMan.add("xeen", _archives[0]);
sideNum = 1;
}
if (vm->getGameID() == GType_DarkSide || vm->getGameID() == GType_WorldOfXeen) {
_archives[sideNum] = new CCArchive("dark.cc", "dark", true);
SearchMan.add("dark", _archives[sideNum]);
}
if (f.exists("intro.cc")) {
_archives[2] = new CCArchive("intro.cc", "intro", true);
SearchMan.add("intro", _archives[2]);
}
}
示例11: fileExists
bool CFilesManager::fileExists(const CString &name) {
Common::File f;
return f.exists(name);
}
示例12: exists
bool Resources::exists(const Common::String &filename) const {
Common::File f;
return f.exists(filename) || _cache.isCached(filename);
}
示例13: existFile
bool FileManager::existFile(const Common::String &filename) {
Common::File f;
return f.exists(filename);
}
示例14: loadSpriteBank
/**
* Load Sprite Bank
*/
int AnimationManager::loadSpriteBank(int idx, const Common::String &filename) {
int result = 0;
Bank[idx]._loadedFl = true;
Bank[idx]._filename = filename;
byte *fileDataPtr = _vm->_fileIO->loadFile(filename);
Bank[idx]._fileHeader = 0;
if (fileDataPtr[1] == 'L' && fileDataPtr[2] == 'E')
Bank[idx]._fileHeader = 1;
else if (fileDataPtr[1] == 'O' && fileDataPtr[2] == 'R')
Bank[idx]._fileHeader = 2;
if (!Bank[idx]._fileHeader) {
_vm->_globals->freeMemory(fileDataPtr);
Bank[idx]._loadedFl = false;
result = -1;
}
Bank[idx]._data = fileDataPtr;
int objectDataIdx = 0;
for(objectDataIdx = 0; objectDataIdx <= 249; objectDataIdx++) {
int width = _vm->_objectsMan->getWidth(fileDataPtr, objectDataIdx);
int height = _vm->_objectsMan->getHeight(fileDataPtr, objectDataIdx);
if (!width && !height)
break;
}
if (objectDataIdx > 249) {
_vm->_globals->freeMemory(fileDataPtr);
Bank[idx]._loadedFl = false;
result = -2;
}
Bank[idx]._objDataIdx = objectDataIdx;
Common::String ofsFilename = Bank[idx]._filename;
char ch;
do {
ch = ofsFilename.lastChar();
ofsFilename.deleteLastChar();
} while (ch != '.');
ofsFilename += ".OFS";
Common::File f;
if (f.exists(ofsFilename)) {
byte *ofsData = _vm->_fileIO->loadFile(ofsFilename);
byte *curOfsData = ofsData;
for (int objIdx = 0; objIdx < Bank[idx]._objDataIdx; ++objIdx, curOfsData += 8) {
int x1 = READ_LE_INT16(curOfsData);
int y1 = READ_LE_INT16(curOfsData + 2);
int x2 = READ_LE_INT16(curOfsData + 4);
int y2 = READ_LE_INT16(curOfsData + 6);
_vm->_objectsMan->setOffsetXY(Bank[idx]._data, objIdx, x1, y1, 0);
if (Bank[idx]._fileHeader == 2)
_vm->_objectsMan->setOffsetXY(Bank[idx]._data, objIdx, x2, y2, 1);
}
_vm->_globals->freeMemory(ofsData);
result = 0;
}
return result;
}
示例15: fileExists
/**
* Check if a file is present
*/
bool FileManager::fileExists(const Common::String &file) {
Common::File f;
return f.exists(file);
}