本文整理汇总了C++中wxFileName::FileExists方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFileName::FileExists方法的具体用法?C++ wxFileName::FileExists怎么用?C++ wxFileName::FileExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFileName
的用法示例。
在下文中一共展示了wxFileName::FileExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsFileExists
static bool IsFileExists(const wxFileName& filename)
{
#ifdef __WXMSW__
/* wxString drive = filename.GetVolume();
if(drive.Length()>1)
return false;*/
return filename.FileExists();
#else
return filename.FileExists();
#endif
}
示例2: Test_Date
int Test_Date(wxString FileName)
{
FN.Assign(FileName);
if (!FN.FileExists())
{
ToShow+=FileName;
ToShow+=__T(" does not exist");
return -1;
}
if (!FN.GetTimes(&Access, NULL, NULL))
{
ToShow+=__T("Error getting date of ");
ToShow+=FileName;
return -1;
}
wxTimeSpan TS=wxDateTime::Now()-Access;
if (TS.GetWeeks()>0 || TS.GetDays()>0 || TS.GetHours()>0 || TS.GetMinutes()>0)
{
ToShow+=FileName;
ToShow+=__T(" is old : was compiled");
ToShow+=TS.Format().c_str();
ToShow+=__T(" ago\r\n");
}
return 0;
}
示例3: FileHistoryPopupMenu
void wxExFrameWithHistory::FileHistoryPopupMenu()
{
wxMenu* menu = new wxMenu();
for (int i = 0; i < m_FileHistory.GetCount(); i++)
{
const wxFileName file(m_FileHistory.GetHistoryFile(i));
if (file.FileExists())
{
wxMenuItem* item = new wxMenuItem(
menu,
wxID_FILE1 + i,
file.GetFullName());
item->SetBitmap(wxTheFileIconsTable->GetSmallImageList()->GetBitmap(
wxExGetIconID(file)));
menu->Append(item);
}
}
if (menu->GetMenuItemCount() > 0)
{
menu->AppendSeparator();
menu->Append(ID_CLEAR, wxGetStockLabel(wxID_CLEAR));
PopupMenu(menu);
}
delete menu;
}
示例4: IsModified
bool GPCB_FPL_CACHE_ITEM::IsModified() const
{
if( !m_file_name.FileExists() )
return false;
return m_file_name.GetModificationTime() != m_mod_time;
}
示例5: DoExport
bool ExportMultiple::DoExport(int channels,
wxFileName name,
bool selectedOnly,
double t0,
double t1,
Tags tags)
{
// Generate a unique name if we're not allowed to overwrite
if (!mOverwrite->GetValue()) {
int i = 2;
wxString base(name.GetName());
while (name.FileExists()) {
name.SetName(wxString::Format(wxT("%s-%d"), base.c_str(), i++));
}
}
// Call the format export routine
bool rc = mPlugins[mFormatIndex]->Export(mProject,
channels,
name.GetFullPath(),
selectedOnly,
t0,
t1,
NULL,
&tags);
return rc;
}
示例6: EnumerateMemoryCard
//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc)
bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const wxDirName basePath )
{
dest.IsFormatted = false;
dest.IsPresent = false;
const wxString fullpath( filename.GetFullPath() );
if( !filename.FileExists() ) return false;
DevCon.WriteLn( fullpath );
wxFFile mcdFile( fullpath );
if( !mcdFile.IsOpened() ) return false; // wx should log the error for us.
if( mcdFile.Length() < (1024*528) )
{
Console.Warning( "... MemoryCard appears to be truncated. Ignoring." );
return false;
}
dest.IsPresent = true;
dest.Filename = filename;
if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() )
dest.Filename = filename.GetFullName();
dest.SizeInMB = (uint)(mcdFile.Length() / (1024 * 528 * 2));
dest.IsFormatted = IsMcdFormatted( mcdFile );
filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated );
return true;
}
示例7: clException
void
clPatch::Patch(const wxFileName& patchFile, const wxString& workingDirectory, const wxString& args)
{
// Sanity
if(!m_patch.FileExists()) {
throw clException("Could not locate patch executable");
}
if(!patchFile.FileExists()) {
throw clException("Patch failed. File: '" + patchFile.GetFullPath() + "' does not exist");
}
// Prepare the command
wxString command;
command << m_patch.GetFullPath();
::WrapWithQuotes(command);
if(!args.IsEmpty()) {
command << " " << args;
}
// Change directory to the working directory requested by the user
DirSaver ds;
wxSetWorkingDirectory(workingDirectory.IsEmpty() ? ::wxGetCwd() : workingDirectory);
wxString patch = patchFile.GetFullPath();
command << " " << ::WrapWithQuotes(patch);
::WrapInShell(command);
ProcUtils::SafeExecuteCommand(command);
}
示例8: EnumerateMemoryCard
//sets IsPresent if the file is valid, and derived properties (filename, formatted, size, etc)
bool EnumerateMemoryCard( McdSlotItem& dest, const wxFileName& filename, const wxDirName basePath )
{
dest.IsFormatted = false;
dest.IsPresent = false;
dest.IsPSX = false;
dest.Type = MemoryCardType::MemoryCard_None;
const wxString fullpath( filename.GetFullPath() );
//DevCon.WriteLn( fullpath );
if ( filename.FileExists() ) {
// might be a memory card file
wxFFile mcdFile( fullpath );
if ( !mcdFile.IsOpened() ) { return false; } // wx should log the error for us.
wxFileOffset length = mcdFile.Length();
if( length < (1024*528) && length != 0x20000 )
{
Console.Warning( "... MemoryCard appears to be truncated. Ignoring." );
return false;
}
dest.SizeInMB = (uint)( length / ( 1024 * 528 * 2 ) );
if ( length == 0x20000 ) {
dest.IsPSX = true; // PSX memcard;
dest.SizeInMB = 1; // MegaBIT
}
dest.Type = MemoryCardType::MemoryCard_File;
dest.IsFormatted = IsMcdFormatted( mcdFile );
filename.GetTimes( NULL, &dest.DateModified, &dest.DateCreated );
} else if ( filename.DirExists() ) {
// might be a memory card folder
wxFileName superBlockFileName( fullpath, L"_pcsx2_superblock" );
if ( !superBlockFileName.FileExists() ) { return false; }
wxFFile mcdFile( superBlockFileName.GetFullPath() );
if ( !mcdFile.IsOpened() ) { return false; }
dest.SizeInMB = 0;
dest.Type = MemoryCardType::MemoryCard_Folder;
dest.IsFormatted = IsMcdFormatted( mcdFile );
superBlockFileName.GetTimes( NULL, &dest.DateModified, &dest.DateCreated );
} else {
// is neither
return false;
}
dest.IsPresent = true;
dest.Filename = filename;
if( filename.GetFullPath() == (basePath+filename.GetFullName()).GetFullPath() )
dest.Filename = filename.GetFullName();
return true;
}
示例9: wxCHECK_RET
void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName )
{
wxCHECK_RET( aProjectFileName.DirExists() && aProjectFileName.IsDirWritable(),
"Project folder must exist and be writable to create a new project." );
// Init project filename. This clears all elements from the project object.
SetProjectFileName( aProjectFileName.GetFullPath() );
// Copy kicad.pro file from template folder.
if( !aProjectFileName.FileExists() )
{
wxString srcFileName = sys_search().FindValidPath( "kicad.pro" );
// Create a minimal project (.pro) file if the template project file could not be copied.
if( !wxFileName::FileExists( srcFileName )
|| !wxCopyFile( srcFileName, aProjectFileName.GetFullPath() ) )
{
Prj().ConfigSave( PgmTop().SysSearch(), GeneralGroupName, s_KicadManagerParams );
}
}
// Ensure a "stub" for a schematic root sheet and a board exist.
// It will avoid messages from the schematic editor or the board editor to create a new file
// And forces the user to create main files under the right name for the project manager
wxFileName fn( aProjectFileName.GetFullPath() );
fn.SetExt( SchematicFileExtension );
// If a <project>.sch file does not exist, create a "stub" file ( minimal schematic file )
if( !fn.FileExists() )
{
wxFile file( fn.GetFullPath(), wxFile::write );
if( file.IsOpened() )
file.Write( wxT( "EESchema Schematic File Version 2\n"
"EELAYER 25 0\nEELAYER END\n$EndSCHEMATC\n" ) );
// wxFile dtor will close the file
}
// If a <project>.kicad_pcb or <project>.brd file does not exist,
// create a .kicad_pcb "stub" file
fn.SetExt( KiCadPcbFileExtension );
wxFileName leg_fn( fn );
leg_fn.SetExt( LegacyPcbFileExtension );
if( !fn.FileExists() && !leg_fn.FileExists() )
{
wxFile file( fn.GetFullPath(), wxFile::write );
if( file.IsOpened() )
file.Write( wxT( "(kicad_pcb (version 4) (host kicad \"dummy file\") )\n" ) );
// wxFile dtor will close the file
}
}
示例10: GetMinecraftJarVersion
wxString GetMinecraftJarVersion(wxFileName jar)
{
wxString fullpath = jar.GetFullPath();
wxString version = MCVer_Unknown;
if(!jar.FileExists())
return version;
std::auto_ptr<wxZipEntry> entry;
// convert the local name we are looking for into the internal format
wxString name = wxZipEntry::GetInternalName("net/minecraft/client/Minecraft.class",wxPATH_UNIX);
// open the zip
wxFFileInputStream inStream(jar.GetFullPath());
wxZipInputStream zipIn(inStream);
// call GetNextEntry() until the required internal name is found
do
{
entry.reset(zipIn.GetNextEntry());
}
while (entry.get() != NULL && entry->GetInternalName() != name);
auto myentry = entry.get();
if (myentry == NULL)
return version;
// we got the entry, read the data
std::size_t size = myentry->GetSize();
char *classdata = new char[size];
zipIn.Read(classdata,size);
try
{
char * temp = classdata;
java::classfile Minecraft_jar(temp,size);
auto cnst = Minecraft_jar.constants;
auto iter = cnst.begin();
while (iter != cnst.end())
{
const java::constant & constant = *iter;
if(constant.type != java::constant::j_string_data)
{
iter++;
continue;
}
auto & str = constant.str_data;
const char * lookfor = "Minecraft Minecraft "; // length = 20
if(str.compare(0,20,lookfor) == 0)
{
version = str.substr(20).data();
break;
}
iter++;
}
} catch(java::classfile_exception &){}
delete[] classdata;
return version;
}
示例11: BlockFile
/// Construct a SimpleBlockFile memory structure that will point to an
/// existing block file. This file must exist and be a valid block file.
///
/// @param existingFile The disk file this SimpleBlockFile should use.
SimpleBlockFile::SimpleBlockFile(wxFileName existingFile, sampleCount len,
float min, float max, float rms):
BlockFile(existingFile, len)
{
if( !existingFile.FileExists() )
// throw an exception?
;
mMin = min;
mMax = max;
mRMS = rms;
}
示例12: LoadForFile
bool clEditorConfig::LoadForFile(const wxFileName& filename, wxFileName& editorConfigFile)
{
editorConfigFile = wxFileName(filename.GetPath(), ".editorconfig");
bool foundFile = false;
while(editorConfigFile.GetDirCount()) {
if(editorConfigFile.FileExists()) {
foundFile = true;
break;
}
editorConfigFile.RemoveLastDir();
}
if(!foundFile) return false;
wxString content;
if(!FileUtils::ReadFileContent(editorConfigFile, content)) {
clDEBUG() << "Failed to read file:" << editorConfigFile << clEndl;
return false;
}
clEditorConfigSection section;
m_sections.push_back(section);
clEditorConfigSection* cursection = &(m_sections.back());
wxUnusedVar(cursection); // for debug purposes
wxArrayString lines = ::wxStringTokenize(content, "\n", wxTOKEN_STRTOK);
for(size_t i = 0; i < lines.size(); ++i) {
// Remove comments
wxString strLine = lines.Item(i);
strLine = strLine.BeforeFirst('#');
strLine = strLine.BeforeFirst(';');
strLine.Trim().Trim(false);
if(strLine.IsEmpty()) continue;
// Process the line
if(strLine.StartsWith("[") && strLine.EndsWith("]")) {
strLine.RemoveLast().Remove(0, 1); // remove the []
clEditorConfigSection section;
section.patterns = ProcessSection(strLine);
m_sections.push_back(section);
cursection = &(m_sections.back());
} else {
ProcessDirective(strLine);
}
}
clDEBUG() << "Using .editorconfig file:" << editorConfigFile << clEndl;
return true;
}
示例13: NotifyExplorerToRefreshPath
void sg_treediff_cache::NotifyExplorerToRefreshPath(SG_context * pCtx, wxFileName path, bool bSpecific)
{
SG_string * pstrFullPath = NULL;
wxString fullName = path.GetFullName();
SG_ERR_CHECK( SG_STRING__ALLOC__SZ(pCtx, &pstrFullPath, path.GetFullPath().ToUTF8()) );
//Use %s to handle getting a path that has a %s in it.
//SG_ERR_CHECK( SG_UTF8__INTERN_FROM_OS_BUFFER(pCtx, pstrFullPath, path.GetFullPath().ToStdWstring()) );
//SG_log__report_verbose(pCtx, "FS_CHANGE(%s): %s", (const char *)ExplainAction(dwAction), SG_string__sz(pstrFullPath));
{
clearCache(pCtx);
if (!m_bIsWin7) //if we're running on XP or Vista
{
wxCriticalSectionLocker lock(m_notify_critical_section);
m_bHaveGottenNewFileChanges = true;
//For some reason, on XP and Vista, we need to notify for every folder up to the root.
if (path.FileExists() || path.DirExists())
{
if (m_aPathsToNotify.Index(path.GetFullPath()) == wxNOT_FOUND)
m_aPathsToNotify.Add(path.GetFullPath());
}
wxFileName currentDir = wxFileName::DirName(path.GetPath(wxPATH_GET_VOLUME));
wxFileName topDir = GetTopDir();
//currentDir = topDir;
while (topDir.GetDirCount() < currentDir.GetDirCount())
{
if (m_aPathsToNotify.Index(currentDir.GetFullPath()) == wxNOT_FOUND)
m_aPathsToNotify.Add(currentDir.GetFullPath());
currentDir.RemoveLastDir();
}
}
else
{
wxCriticalSectionLocker lock(m_notify_critical_section);
m_bHaveGottenNewFileChanges = true;
//On Win 7, just notifying for the top of the working folder
//will cause a recursive refresh down the tree.
if (m_aPathsToNotify.Index(GetTopDir().GetFullPath()) == wxNOT_FOUND)
m_aPathsToNotify.Add(GetTopDir().GetFullPath());
if (bSpecific)
m_aPathsToNotify.Add(path.GetFullPath());
}
}
fail:
return;
}
示例14: LoadJSON
void ColoursAndFontsManager::LoadJSON(const wxFileName& path)
{
if(!path.FileExists()) return;
JSONRoot root(path);
JSONElement arr = root.toElement();
int arrSize = arr.arraySize();
CL_DEBUG("Loading JSON file: %s (contains %d lexers)", path.GetFullPath(), arrSize);
for(int i = 0; i < arrSize; ++i) {
JSONElement json = arr.arrayItem(i);
DoAddLexer(json);
}
CL_DEBUG("Loading JSON file...done");
}
示例15: LoadConfig
void pkgDecompiler::LoadConfig( const wxFileName& path )
{
SW_DEF(sw);
ScriptFile = path;
if( !path.FileExists() )
throw exception( wxString::Format( wxT("Can't open file %s"), path.GetFullPath().c_str() ).c_str() );
ScriptFormat.SetRoot(NULL);
ScriptFormat.Load(path.GetFullPath());
if( !ScriptFormat.IsOk() )
throw exception( wxString::Format( wxT("File %s contains invalid data."), path.GetFullPath().c_str() ).c_str() );
SW_LOGF(sw);
}