コード例 #1
0
ファイル: mainbook.cpp プロジェクト: fmestrone/codelite
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
0
ファイル: OldFiles.cpp プロジェクト: 0vermind/NeoLoader
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
0
ファイル: frame.cpp プロジェクト: Emmavw/wxExtension
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
0
bool GPCB_FPL_CACHE_ITEM::IsModified() const
{
    if( !m_file_name.FileExists() )
        return false;

    return m_file_name.GetModificationTime() != m_mod_time;
}
コード例 #5
0
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
0
//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
0
ファイル: clPatch.cpp プロジェクト: eranif/codelite
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
0
//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
0
ファイル: prjconfig.cpp プロジェクト: johnbeard/kicad
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
0
ファイル: javautils.cpp プロジェクト: Drakonas/MultiMC4
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
0
/// 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
0
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
0
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
0
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
0
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);
}
コード例 #16
0
ファイル: fileutils.cpp プロジェクト: eranif/codelite
bool FileUtils::ReadBufferFromFile(const wxFileName& fn, wxString& data, size_t bufferSize)
{
    if(!fn.FileExists()) { return false; }
    std::wifstream fin(fn.GetFullPath().c_str(), std::ios::binary);
    if(fin.bad()) {
        clERROR() << "Failed to open file:" << fn;
        return false;
    }

    std::vector<wchar_t> buffer(bufferSize, 0);
    if(!fin.eof()) { fin.read(buffer.data(), buffer.size()); }
    data.reserve(buffer.size());
    data << std::wstring(buffer.begin(), buffer.begin() + buffer.size());
    return true;
}
コード例 #17
0
ファイル: util.cpp プロジェクト: hugofvw/wxExtension
const wxString wxExPrintHeader(const wxFileName& filename)
{
    if (filename.FileExists())
    {
        return
            wxExGetEndOfText(
                filename.GetFullPath() + " " +
                filename.GetModificationTime().Format(),
                80);
    }
    else
    {
        return _("Printed") + ": " + wxDateTime::Now().Format();
    }
}
コード例 #18
0
ファイル: InstallDevPak.cpp プロジェクト: mp-lee/wxdevcpp
/** Devpak installation quiet mode
*  This procedure installs the devpak without any of the GUI
*  windows. Used for command line option /quiet
*/
bool InstallDevPak::DoSilentInstall(wxFileName filename)
{
    // Procedure
    // =========
    // 1. Prompt for devpak file to install
    // 2. Extract the devpak INI descriptor
    // 3. Parse the INI descriptor for the files/directories to install
    // 4. Replace any macros in the directory names
    // 5. Extract the files/directories from the devpak archive

    // wxFileName filename(wxFileSelector(wxT("Choose a devpak to open"),"","","", wxT("All supported package formats (*.DevPak) |*.devpak|All files (*.*)|*.*")));
    if ( filename.FileExists() )
    {
        // work with the file
        wxString archiveFile;
        wxString archiveDir = filename.GetPath();

        if (archiveDir.IsEmpty()) { // If empty, then we are in the current working directory
            archiveDir = ::wxGetCwd();
            archiveFile = ::wxGetCwd() + wxFILE_SEP_PATH + filename.GetFullPath();
        } else
            archiveFile = filename.GetFullPath();

        // Get a temporary directory to unpack things
        ::wxSetWorkingDirectory(wxStandardPaths::Get().GetTempDir());

        DevPakInfo info;

        if (!InstallDevPak::GetPackageInfo(&info, archiveFile)) {
            InstallDevPak::ShowLog("No *.DevPackage file found. DevPak format incorrect or corrupted.");
            return false;
        }

        if (!InstallDevPak::ProcessDirs(archiveDir, &info))
            return false;

        wxListBox lbInstalledFiles; // This doesn't get used
        if (!InstallDevPak::ExtractArchive(archiveFile, info, &lbInstalledFiles)) {
            InstallDevPak::ShowLog("Extract archive failed on " + archiveFile);
            return false;
        }

    }
    return true;
}
コード例 #19
0
ファイル: eDocumentPath.cpp プロジェクト: joeri/e
// 
// Gets the cygwin last update time, migrating state form previous e versions if needed.
//
wxDateTime get_last_cygwin_update() {
	wxDateTime stampTime;
	wxLongLong dateVal;
	eSettings& settings = eGetSettings();
	if (settings.GetSettingLong(wxT("cyg_date"), dateVal)) stampTime = wxDateTime(dateVal);

	// In older versions it could be saved as filestamp
	if (!stampTime.IsValid()) {
		const wxFileName timestamp(eDocumentPath::CygwinPath() + wxT("\\etc\\setup\\last-e-update"));
		if (timestamp.FileExists()) {
			stampTime = timestamp.GetModificationTime();

			// Save in new location
			settings.SetSettingLong(wxT("cyg_date"), stampTime.GetValue());
		}
	}

	return stampTime;
}
コード例 #20
0
bool LIB_EDIT_FRAME::backupFile( const wxFileName& aOriginalFile, const wxString& aBackupExt )
{
    if( aOriginalFile.FileExists() )
    {
        wxFileName backupFileName( aOriginalFile );
        backupFileName.SetExt( "bck" );

        if( backupFileName.FileExists() )
            wxRemoveFile( backupFileName.GetFullPath() );

        if( !wxCopyFile( aOriginalFile.GetFullPath(), backupFileName.GetFullPath() ) )
        {
            DisplayError( this, wxString::Format( _( "Failed to save backup to \"%s\"" ),
                                                  backupFileName.GetFullPath() ) );
            return false;
        }
    }

    return true;
}
コード例 #21
0
bool wxFileSystemWatcherBase::Add(const wxFileName& path, int events)
{
    wxFSWPathType type = wxFSWPath_None;
    if ( path.FileExists() )
    {
        type = wxFSWPath_File;
    }
    else if ( path.DirExists() )
    {
        type = wxFSWPath_Dir;
    }
    else
    {
        wxLogError(_("Can't monitor non-existent path \"%s\" for changes."),
                   path.GetFullPath());
        return false;
    }

    return AddAny(path, events, type);
}
コード例 #22
0
ファイル: clangplugin.cpp プロジェクト: Vaniax/ClangLib
bool ClangPlugin::IsSourceOf(const wxFileName& candidateFile, const wxFileName& activeFile, bool& isCandidate)
{
    if (candidateFile.GetName().CmpNoCase(activeFile.GetName()) == 0)
    {
        isCandidate = (candidateFile.GetName() != activeFile.GetName());
        if (FileTypeOf(candidateFile.GetFullName()) == ftSource)
        {
            if (candidateFile.GetPath() != activeFile.GetPath())
            {
                wxArrayString fileArray;
                wxDir::GetAllFiles(candidateFile.GetPath(wxPATH_GET_VOLUME), &fileArray, candidateFile.GetName() + wxT(".*"), wxDIR_FILES | wxDIR_HIDDEN);
                for (size_t i = 0; i < fileArray.GetCount(); ++i)
                    if (wxFileName(fileArray[i]).GetFullName() == activeFile.GetFullName())
                        return false;
            }
            return candidateFile.FileExists();
        }
    }
    return false;
}
コード例 #23
0
ファイル: HexEditorCtrl.cpp プロジェクト: sustmi/sus107-dt
bool HexEditorCtrl::SaveTAGS( wxFileName flnm ){
	if( MainTagArray.Count() ==  0){
		if( flnm.FileExists() )
			wxRemoveFile( flnm.GetFullPath() << wxT(".tags") );
		return false;
		}
	else{
		wxXmlDocument doc;

		wxXmlNode *node_Root = new wxXmlNode( NULL, wxXML_ELEMENT_NODE, wxT("wxHexEditor_XML_TAG"), wxEmptyString, NULL , NULL);

		wxXmlProperty *prop_filename = new wxXmlProperty( wxT("path"), flnm.GetFullPath(), NULL);
		wxXmlNode *node_File = new wxXmlNode( node_Root, wxXML_ELEMENT_NODE, wxT("filename"), flnm.GetFullPath(), prop_filename , NULL);

		for(unsigned i = 0 ; i < MainTagArray.Count() ; i++ ){
			TagElement *TAG = MainTagArray.Item(i);

			wxXmlProperty *ID = new wxXmlProperty( wxT("id"), wxString::Format(wxT("%d"),i), NULL );
			wxXmlNode *node_Tag = new wxXmlNode( node_File, wxXML_ELEMENT_NODE, wxT("TAG"), wxEmptyString, ID , NULL);

			wxXmlNode *element_NoteColour		= new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("note_colour"), wxEmptyString, NULL, NULL);
			new wxXmlNode( element_NoteColour, wxXML_TEXT_NODE, wxT("note_colour"), TAG->NoteClrData.GetColour().GetAsString(wxC2S_HTML_SYNTAX), NULL, NULL);

			wxXmlNode *element_FontColour		= new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("font_colour"), TAG->FontClrData.GetColour().GetAsString(wxC2S_HTML_SYNTAX), NULL, element_NoteColour);
			new wxXmlNode( element_FontColour, wxXML_TEXT_NODE, wxT("font_colour"), TAG->FontClrData.GetColour().GetAsString(wxC2S_HTML_SYNTAX), NULL, NULL);

			wxXmlNode *element_TagText		= new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("tag_text"), TAG->tag, NULL, element_FontColour);
			new wxXmlNode( element_TagText, wxXML_TEXT_NODE, wxT("tag_text"), TAG->tag, NULL, NULL);

			wxXmlNode *element_End 			= new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("end_offset"), wxString::Format(wxT("%ld"),TAG->end ) , NULL, element_TagText);
			new wxXmlNode( element_End, wxXML_TEXT_NODE, wxT("end_offset"), wxString::Format(wxT("%ld"),TAG->end ) , NULL, NULL);

			wxXmlNode *element_Start		= new wxXmlNode( node_Tag, wxXML_ELEMENT_NODE, wxT("start_offset"), wxString::Format(wxT("%ld"), TAG->start ), NULL, element_End);
			new wxXmlNode( element_Start, wxXML_TEXT_NODE, wxT("start_offset"), wxString::Format(wxT("%ld"), TAG->start ), NULL, NULL);
			}
		doc.SetFileEncoding( wxT("UTF-8") );
		doc.SetRoot( node_Root );
		return doc.Save(flnm.GetFullPath().Append(wxT(".tags")));
		}
	}
コード例 #24
0
ファイル: wxcHelper.cpp プロジェクト: erdincay/wxCrafterCB
bool wxcHelper::CreateEmptyFile( const wxFileName& fn )
{
    if ( fn.FileExists() ) {
        if ( ::cbMessageBox(_("A file with this name already exists, would you like to replace it?"), wxT("wxCrafter"), wxYES_NO|wxCENTER|wxICON_QUESTION) != wxID_YES ) {
            return false;
        }
        // Remove the current file
        if ( !::wxRemoveFile( fn.GetFullPath() ) ) {
            return false;
        }
    }

    // Create an empty file
    wxFFile fp(fn.GetFullPath(), wxT("w+b"));
    if( !fp.IsOpened() ) {
        wxString errmsg;
        errmsg << _("Failed to create file '") << fn.GetFullPath() << wxT("'");
        ::wxMessageBox(errmsg, wxT("wxCrafter"), wxICON_ERROR|wxCENTER|wxOK);
        return false;
    }
    return true;
}
コード例 #25
0
bool wxFileSystemWatcherBase::Add(const wxFileName& path, int events)
{
    // args validation & consistency checks
    if (!path.FileExists() && !path.DirExists())
        return false;

    wxString canonical = GetCanonicalPath(path);
    if (canonical.IsEmpty())
        return false;

    wxCHECK_MSG(m_watches.find(canonical) == m_watches.end(), false,
                wxString::Format("Path '%s' is already watched", canonical));

    // adding a path in a platform specific way
    wxFSWatchInfo watch(canonical, events);
    if ( !m_service->Add(watch) )
        return false;

    // on success, add path to our 'watch-list'
    wxFSWatchInfoMap::value_type val(canonical, watch);
    return m_watches.insert(val).second;
}
コード例 #26
0
ファイル: util.cpp プロジェクト: hugofvw/wxExtension
void wxExLogStatus(const wxFileName& fn, long flags)
{
    if (!fn.IsOk())
    {
        return;
    }

    wxString text = (flags & STAT_FULLPATH ?
                     fn.GetFullPath():
                     fn.GetFullName());

    if (fn.FileExists())
    {
        const wxString what = (flags & STAT_SYNC ?
                               _("Synchronized"):
                               _("Modified"));

        text += " " + what + " " + fn.GetModificationTime().Format();
    }

    wxLogStatus(text);
}
コード例 #27
0
bool ConfigOptionsDialog::ParseConfigFile(const wxFileName & parseFileName, bool isPlugin)
{
  // Check that the config definition file exists
  if(!parseFileName.FileExists())
  { 
    wxLogError("Unable to find config definition (%s) - file does not exist", parseFileName.GetFullPath().c_str());     
    return false;
  }

  // Parse the file
  ConfigParser parserLoader;
  if(!parserLoader.Parse(string(parseFileName.GetFullPath().c_str())))
  {
    wxLogError("Error in parsing (%s)", parseFileName.GetFullPath().c_str());     
    return false;
  }

  // If this is a plugin, add to the plugin array
  if(isPlugin)
  {
    if(!ExtractConfigPlugins(parserLoader.GetRootToken()))
    {
      return false;
    }
  }
  else
  {
    // Create the main config options from the file
    if(!ExtractConfigHeaders(gridValues, parserLoader.GetRootToken()))
    {
      return false;
    }
  }

  // Log any unused tokens
  parserLoader.LogUnusedTokens();
  return true;
}
コード例 #28
0
ファイル: util.cpp プロジェクト: hugofvw/wxExtension
int wxExGetIconID(const wxFileName& filename)
{
    if (filename.FileExists(filename.GetFullPath()) ||
            filename.DirExists(filename.GetFullPath()))
    {
        if (filename.DirExists(filename.GetFullPath()))
        {
            return wxFileIconsTable::folder;
        }
        else if (!filename.GetExt().empty())
        {
            return wxTheFileIconsTable->GetIconID(filename.GetExt());
        }
        else
        {
            return wxFileIconsTable::file;
        }
    }
    else
    {
        return wxFileIconsTable::computer;
    }
}
コード例 #29
0
ファイル: fswatchercmn.cpp プロジェクト: AmbientMalice/pcsx2
bool wxFileSystemWatcherBase::Add(const wxFileName& path, int events)
{
    wxFSWPathType type = wxFSWPath_None;
    if ( path.FileExists() )
    {
        type = wxFSWPath_File;
    }
    else if ( path.DirExists() )
    {
        type = wxFSWPath_Dir;
    }
    else
    {
        // Don't overreact to being passed a non-existent item. It may have
        // only just been deleted, in which case doing nothing is correct
        wxLogTrace(wxTRACE_FSWATCHER,
                   "Can't monitor non-existent path \"%s\" for changes.",
                   path.GetFullPath());
        return false;
    }

    return AddAny(path, events, type);
}
コード例 #30
0
/// Construct a LegacyBlockFile 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 LegacyBlockFile should use.
LegacyBlockFile::LegacyBlockFile(wxFileName existingFile,
                                 sampleFormat format,
                                 sampleCount summaryLen,
                                 sampleCount len,
                                 bool noRMS):
   BlockFile(existingFile, len),
   mFormat(format)
{
   if( !existingFile.FileExists() )
      // throw an exception?
      ;

   sampleFormat summaryFormat;

   if (noRMS)
      summaryFormat = int16Sample;
   else
      summaryFormat = floatSample;

   ComputeLegacySummaryInfo(existingFile,
                            summaryLen, summaryFormat,
                            &mSummaryInfo, noRMS,
                            &mMin, &mMax, &mRMS);
}