Esempio n. 1
0
QTSS_Error QTSSModule::LoadFromDisk(QTSS_MainEntryPointPtr* outEntrypoint)
{
	static StrPtrLen sMainEntrypointName("_Main");

	Assert(outEntrypoint != NULL);

	// Modules only need to be initialized if they reside on disk. 
	if (fFragment == NULL)
		return QTSS_NoErr;

	if (!fFragment->IsValid())
		return QTSS_NotAModule;

	// fPath is actually a path. Extract the file name.

	StrPtrLen theFileName(fPath);
	StringParser thePathParser(&theFileName);

	while (thePathParser.GetThru(&theFileName, kPathDelimiterChar))
		;
	Assert(theFileName.Len > 0);
	Assert(theFileName.Ptr != NULL);

#ifdef __Win32__
	StringParser theDLLTruncator(&theFileName);
	theDLLTruncator.ConsumeUntil(&theFileName, '.'); // strip off the ".DLL"
#endif

	/** 08/16/01 quellish **/

#if __MacOSX__
	StringParser theBundleTruncator(&theFileName);
	theBundleTruncator.ConsumeUntil(&theFileName, '.'); // strip off the ".bundle"
#endif

	// At this point, theFileName points to the file name. Make this the module name.
	this->SetValue(qtssModName, 0, theFileName.Ptr, theFileName.Len, QTSSDictionary::kDontObeyReadOnly);

	// 
	// The main entrypoint symbol name is the file name plus that _Main__ string up there.
	OSCharArrayDeleter theSymbolName(new char[theFileName.Len + sMainEntrypointName.Len + 2]);
	::memcpy(theSymbolName, theFileName.Ptr, theFileName.Len);
	theSymbolName[theFileName.Len] = '\0';

	::strcat(theSymbolName, sMainEntrypointName.Ptr);
	*outEntrypoint = (QTSS_MainEntryPointPtr)fFragment->GetSymbol(theSymbolName.GetObject());
	return QTSS_NoErr;
}
Esempio n. 2
0
void	HLFileSystemObject::SetName(CFStringRef inName)
{
	//	the FSRef for a file can change after renaming,
	//	so don't allow it to be done while the file is open
	ThrowIf(IsOpenForReading() || IsOpenForWriting(), CAException(fBsyErr), "HLFileSystemObject::SetName: can't change the name of an open file");
	
	//	make a raw unicode string out of the CFString
	CACFString theFileName(inName, false);
	UInt32 theFileNameLength = 255;
	UniChar	theFileNameString[255];
	theFileName.GetUnicodeString(theFileNameString, theFileNameLength);
	
	//	save off the current FSRef, since it may change
	FSRef theOldFSRef;
	memcpy(&theOldFSRef, &mFSRef, sizeof(FSRef));
	
	//	rename the file, getting us the new FSRef
	OSStatus theError = FSRenameUnicode(&theOldFSRef, theFileNameLength, theFileNameString, kTextEncodingUnknown, &mFSRef);
	ThrowIfError(theError, CAException(theError), "HLFileSystemObject::SetName: couldn't rename the file");
}
Esempio n. 3
0
bool wxSTEditorNotebook::LoadFiles( wxArrayString *filePaths_,
                                    const wxString &extensions_)
{
    wxString extensions(extensions_.Length() ? extensions_ : GetOptions().GetDefaultFileExtensions());
    wxArrayString filePaths;
    wxString encoding;

    if (filePaths_)
        filePaths = *filePaths_;

    if (filePaths.GetCount() < 1u)
    {
        wxSTEditorFileDialog fileDialog( this, _("Open file(s) into new notebook page"),
                                 GetOptions().GetDefaultFilePath(),
                                 extensions,
                                 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE);

        fileDialog.m_encoding = encoding;
        if (fileDialog.ShowModal() == wxID_OK)
        {
            fileDialog.GetPaths(filePaths);
            encoding = fileDialog.m_encoding;
        }
        else
            return false;
    }

    if (!filePaths.GetCount())
        return false;

    size_t n, count = filePaths.GetCount();
    size_t max_filename_len = 80;
    //for (n = 0; n < count; n++) max_filename_len = wxMax(max_filename_len, filePaths[n].Length());

    wxProgressDialog progDlg(_("Loading files..."),
                             wxString(wxT('_'), max_filename_len + 10), // +10 for file count
                             (int)filePaths.GetCount(), this,
                             wxPD_CAN_ABORT|wxPD_ELAPSED_TIME|wxPD_APP_MODAL|wxPD_AUTO_HIDE);

    // block updating the pages while loading them
    if (m_editorTreeCtrl != NULL) m_editorTreeCtrl->Freeze();
    {
    wxSTERecursionGuard guard(m_rGuard_UpdatePageState);

    for (n = 0; n < count; n++)
    {
        wxString fileName(filePaths[n]);
        wxString progressFileName;
        // Ellipsize filename that are too long.
        if (fileName.Length() > max_filename_len)
            progressFileName = fileName.Mid(0, max_filename_len/2-2) + wxT(" ... ") + fileName.Mid(fileName.Length()-max_filename_len/2+2);
        else
            progressFileName = fileName;

        if (!progDlg.Update((int)n, wxString::Format(wxT("%d/%d : "), (int)n+1, (int)count) + progressFileName))
            break;

        if (fileName.IsEmpty() || !wxFileExists(fileName))
        {
            // when selecting multiple files with file selector you can easily
            // select the dir "..", throw it away
            wxString theFileName(fileName.AfterLast(wxFILE_SEP_PATH));
            if ((theFileName != wxT("..")) && (theFileName != wxT(".")))
            {
                wxSTEditorSplitter *splitter = CreateSplitter(wxID_ANY);
                wxCHECK_MSG(splitter, false, wxT("invalid splitter"));
                splitter->GetEditor()->NewFile(fileName);
                if (!InsertEditorSplitter(-1, splitter)) break; // checks overflow
            }
        }
        else
        {
            if (!LoadFile(fileName, wxEmptyString, encoding)) break;
        }
    }
    }

    UpdatePageState();
    if (m_editorTreeCtrl != NULL)
    {
        m_editorTreeCtrl->Thaw();
        m_editorTreeCtrl->UpdateFromNotebook();
    }

    return true;
}