Ejemplo n.º 1
0
bool D3MFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool checkSig) const
{    
    const std::string extension = GetExtension(pFile);

    if(extension == "3mf")
    {
        return true;
    }
    else if(!extension.length() || checkSig)
    {
        if(!pIOHandler)
            return true;
    }

    return false;
}
Ejemplo n.º 2
0
//================================================================
// Name:				Write
// Class:			DocFileOutput
//	
// Description:	Writes the file to disk
//
// Parameters:		char *filename -- the filename to create
//
// Returns:			None
//
//================================================================
void DocFileOutput::Write(const char *filename, ClassDef *classlist, int ptypeFlag)
{
	char realname[255];
	sprintf(realname,"%s.%s",filename,GetExtension());
	fileptr = fopen(realname,"w");
	if ( !fileptr )
		return;
	
	// Store the type flag privately so we don't have to pass it around
	typeFlag = ptypeFlag;
	
	// Start the writing process
	OutputClasses(classlist);
	
	fclose(fileptr);
}
Ejemplo n.º 3
0
void	CAAudioFileFormats::FileFormatInfo::DebugPrint()
{
	char ftype[20];
	char ftypename[64];
	CFStringGetCString(mFileTypeName, ftypename, sizeof(ftypename), kCFStringEncodingUTF8);
	printf("File type: '%s' = %s\n  Extensions:", OSTypeToStr(ftype, mFileTypeID), ftypename);
	int i, n = NumberOfExtensions();
	for (i = 0; i < n; ++i) {
		GetExtension(i, ftype, sizeof(ftype));
		printf(" .%s", ftype);
	}
	LoadDataFormats();
	printf("\n  Formats:\n");
	for (i = 0; i < mNumDataFormats; ++i)
		mDataFormats[i].DebugPrint();
}
Ejemplo n.º 4
0
void CDesignCollection::SelectAdventure (DWORD dwUNID)

//	SelectAdventure
//
//	Enable the given adventure and disable all other adventures

	{
	int i;

	for (i = 0; i < GetExtensionCount(); i++)
		{
		SExtensionDesc *pEntry = GetExtension(i);
		if (pEntry->iType == extAdventure)
			pEntry->bEnabled = (pEntry->dwUNID == dwUNID);
		}
	}
Ejemplo n.º 5
0
int CExtensionListControl::CListItem::Compare(const CSortingListItem *baseOther, int subitem) const
{
    int r = 0;

    const CListItem *other = (const CListItem *)baseOther;

    switch (subitem)
    {
    case COL_EXTENSION:
        {
            r = signum(GetExtension().CompareNoCase(other->GetExtension()));
        }
        break;

    case COL_COLOR:
    case COL_BYTES:
        {
            r = signum(m_record.bytes - other->m_record.bytes);
        }
        break;

    case COL_FILES:
        {
            r = signum(m_record.files - other->m_record.files);
        }
        break;

    case COL_DESCRIPTION:
        {
            r = signum(GetDescription().CompareNoCase(other->GetDescription()));
        }
        break;

    case COL_BYTESPERCENT:
        {
            r = signum(GetBytesFraction() - other->GetBytesFraction());
        }
        break;

    default:
        {
            ASSERT(0);
        }
    }

    return r;
}
Ejemplo n.º 6
0
 bool HasExtension(const bfs::path& path) {
         // not sure this gives the same results as below
         // because the "." will be included in the extension
         // meaning that this may return true for a path that
         // is simply has an empty extension
         // see link for more information:
         // http://www.boost.org/doc/libs/1_49_0/libs/filesystem/v3/doc/reference.html#path-extension
         //return path.has_extension();
         
         std::string extension = GetExtension(path);
         if (extension.empty() || extension == ".") {
             return false;
         }
         else {
             return true;
         }
 }
Ejemplo n.º 7
0
wxSize Image::ToImageFile(wxString filename)
{
  wxFileName fn(filename);
  wxString ext = fn.GetExt();
  if(filename.Lower().EndsWith(GetExtension().Lower()))
  {
    wxFile file(filename,wxFile::write);
    if(!file.IsOpened())
      return wxSize(-1,-1);
    
    file.Write(m_compressedImage.GetData(), m_compressedImage.GetDataLen());
    if(file.Close())
      return wxSize(m_originalWidth,m_originalHeight);
    else
      return wxSize(-1,-1);
  }
  else
  {
    wxBitmap bitmap = GetUnscaledBitmap();
    wxImage image=bitmap.ConvertToImage();
    wxBitmapType mimetype = wxBITMAP_TYPE_ANY;
    if((ext.Lower() == wxT("jpg")) || (ext.Lower() == wxT("jpeg")))
      mimetype = wxBITMAP_TYPE_JPEG;
    else if(ext.Lower() == wxT("png"))
      mimetype = wxBITMAP_TYPE_PNG;
    else if(ext.Lower() == wxT("pcx"))
      mimetype = wxBITMAP_TYPE_PCX;
    else if(ext.Lower() == wxT("pnm"))
      mimetype = wxBITMAP_TYPE_PNM;
    else if((ext.Lower() == wxT("tif")) || (ext.Lower() == wxT("tiff")))
      mimetype = wxBITMAP_TYPE_TIFF;
    else if(ext.Lower() == wxT("xpm"))
      mimetype = wxBITMAP_TYPE_XPM;
    else if(ext.Lower() == wxT("ico"))
      mimetype = wxBITMAP_TYPE_ICO;
    else if(ext.Lower() == wxT("cur"))
      mimetype = wxBITMAP_TYPE_CUR;
    else
      return(wxSize(-1,-1));
    
    if(!image.SaveFile(filename,mimetype))
      return wxSize(-1,-1);
    return image.GetSize();
  }
}
RETCODE World::EntityLoad_Trigger(hQBSP qbsp, const EntityParse & entityDat)
{
	//create new trigger
	Trigger *newObj = new Trigger; assert(newObj);

	///////////////////////////////////////////////////////
	//load up the common stuff
	EntityLoad_CommonObject(qbsp, entityDat, dynamic_cast<Object *>(newObj));

	const char *pStr;
	int			iVal;

	///////////////////////////////////////////////////////
	//can it only be turned on once?
	pStr = entityDat.GetVal("bOnce");
	if(pStr)
		sscanf(pStr, "%d", &iVal);
	else
		iVal = 0;

	newObj->SetFlag(OBJ_FLAG_ONCE_ONLY, iVal ? true : false);

	//get script file
	char scriptPath[MAXCHARBUFF];

	strcpy(scriptPath, m_filePath.c_str());
	strcpy(GetExtension(scriptPath), SCENE_EXT);

	///////////////////////////////////////////////////////
	//check if we want multiple entities to activate the trigger
	pStr = entityDat.GetVal("bAllowMultiple");
	if(pStr)
	{
		sscanf(pStr, "%d", &iVal);
		newObj->AllowMultipleEntities(iVal == 1 ? true : false);
	}

	///////////////////////////////////////////////////////
	//set the script for 'on'
	pStr = entityDat.GetVal("script");
	if(pStr)
		newObj->LoadScript(scriptPath, pStr);

	return RETCODE_SUCCESS;
}
Ejemplo n.º 9
0
RageSurface *RageSurfaceUtils::LoadFile( const RString &sPath, RString &error, bool bHeaderOnly )
{
	{
		RageFile TestOpen;
		if( !TestOpen.Open( sPath ) )
		{
			error = TestOpen.GetError();
			return NULL;
		}
	}

	set<RString> FileTypes;
	vector<RString> const& exts= ActorUtil::GetTypeExtensionList(FT_Bitmap);
	for(vector<RString>::const_iterator curr= exts.begin();
			curr != exts.end(); ++curr)
	{
		FileTypes.insert(*curr);
	}

	RString format = GetExtension(sPath);
	format.MakeLower();

	bool bKeepTrying = true;

	/* If the extension matches a format, try that first. */
	if( FileTypes.find(format) != FileTypes.end() )
	{
	    RageSurface *ret = TryOpenFile( sPath, bHeaderOnly, error, format, bKeepTrying );
		if( ret )
			return ret;
		FileTypes.erase( format );
	}

	for( set<RString>::iterator it = FileTypes.begin(); bKeepTrying && it != FileTypes.end(); ++it )
	{
		RageSurface *ret = TryOpenFile( sPath, bHeaderOnly, error, *it, bKeepTrying );
		if( ret )
		{
			LOG->UserLog( "Graphic file", sPath, "is really %s", it->c_str() );
			return ret;
		}
	}

	return NULL;
}
Ejemplo n.º 10
0
void CDesignCollection::GetEnabledExtensions (TArray<CExtension *> *retExtensionList)

//	GetEnabledExtensions
//
//	Returns the list of enabled extensions

	{
	int i;

	retExtensionList->DeleteAll();

	for (i = 0; i < GetExtensionCount(); i++)
		{
		CExtension *pEntry = GetExtension(i);
		if (pEntry->GetType() == extExtension)
			retExtensionList->Insert(pEntry);
		}
	}
Ejemplo n.º 11
0
void CDesignCollection::GetEnabledExtensions (TArray<DWORD> *retExtensionList)

//	GetEnabledExtensions
//
//	Returns the list of enabled extensions

	{
	int i;

	retExtensionList->DeleteAll();

	for (i = 0; i < GetExtensionCount(); i++)
		{
		SExtensionDesc *pEntry = GetExtension(i);
		if (pEntry->iType == extExtension && pEntry->bEnabled)
			retExtensionList->Insert(pEntry->dwUNID);
		}
	}
Ejemplo n.º 12
0
BOOL CImage::ReadFile(const CString& fileName, int imageType)
{
        int oldImageType = filetype;
	filename = fileName;

	if (imageType==-1) {
	  imageType = search_formats(GetExtension((char *)(const char *)filename));
	}
        filetype = imageType;

        if (!implementation || (imageType != oldImageType))
        {
          if (!CreateImplementation(filename, imageType))
            return FALSE;
        }
          
        return implementation->ReadFile(filename);
}
Ejemplo n.º 13
0
void CreateOldStyleShortcut(HANDLE hContact, TCHAR *history_filename)
{
	TCHAR shortcut[MAX_PATH] = _T("");

	GetOldStyleAvatarName(shortcut, hContact);

	mir_sntprintf(shortcut, MAX_REGS(shortcut), _T("%s.%s.lnk"), shortcut, 
		GetExtension(history_filename));

	if (!CreateShortcut(history_filename, shortcut))
	{
		ShowPopup(hContact, _T("Avatar History: Unable to create shortcut"), shortcut);
	}
	else
	{
		ShowDebugPopup(hContact, _T("AVH Debug: Shortcut created successfully"), shortcut);
	}
}
void CDlgBOMExport::OnBrowse() 
{
	CString ext = GetExtension();

	// Generate the filter string from the extension
	TCHAR szFilter[256];
	_stprintf_s(szFilter, _T("Parts List (*%s)|*%s|All files (*.*)|*.*||"),
		ext, ext );

	CFileDialog dlg( FALSE, _T("*")+ext, m_Filename, OFN_HIDEREADONLY,
		szFilter, AfxGetMainWnd() ); 

	if (dlg.DoModal() == IDOK)
	{
		m_Filename = dlg.GetPathName();
		UpdateData( FALSE );
	}
}
Ejemplo n.º 15
0
bool SpriteSheet2D::BeginLoad(Deserializer& source)
{
    if (GetName().Empty())
        SetName(source.GetName());

    loadTextureName_.Clear();
    spriteMapping_.Clear();

    String extension = GetExtension(source.GetName());
    if (extension == ".plist")
        return BeginLoadFromPListFile(source);

    if (extension == ".xml")
        return BeginLoadFromXMLFile(source);

    URHO3D_LOGERROR("Unsupported file type");
    return false;
}
Ejemplo n.º 16
0
SoundReader *SoundReader_FileReader::OpenFile( CString filename, CString &error )
{
	{
		RageFile TestOpen;
		if( !TestOpen.Open( filename ) )
		{
			error = TestOpen.GetError();
			return NULL;
		}
	}

	set<CString> FileTypes;
	FileTypes.insert("ogg");
	FileTypes.insert("mp3");
	FileTypes.insert("wav");

	CString format = GetExtension(filename);
	format.MakeLower();

	error = "";

	bool bKeepTrying = true;

	/* If the extension matches a format, try that first. */
	if( FileTypes.find(format) != FileTypes.end() )
	{
	    SoundReader_FileReader *NewSample = TryOpenFile( filename, error, format, bKeepTrying );
		if( NewSample )
			return NewSample;
		FileTypes.erase( format );
	}

	for( set<CString>::iterator it = FileTypes.begin(); bKeepTrying && it != FileTypes.end(); ++it )
	{
	    SoundReader_FileReader *NewSample = TryOpenFile( filename, error, *it, bKeepTrying );
		if( NewSample )
		{
			LOG->Warn("File \"%s\" is really %s", filename.c_str(), it->c_str());
			return NewSample;
		}
	}

	return NULL;
}
Ejemplo n.º 17
0
// little helper function (to stay independent)
void CResourceCompilerHelper::ReplaceExtension(const char* path, const char* new_ext, char* buffer, size_t bufferSizeInBytes)
{
	const char* const ext = GetExtension(path);

	SettingsManagerHelpers::CFixedString<char, 512> p;
	if(ext)
	{
		p.set(path, ext - path);
		p.append(new_ext);
	}
	else
	{
		p.set(path);
		p.append(".");
		p.append(new_ext);
	}

	cry_strcpy(buffer, bufferSizeInBytes, p.c_str());
}
Ejemplo n.º 18
0
bool wxGISDataset::Rename(const wxString &sNewName, ITrackCancel* const pTrackCancel)
{
	wxCriticalSectionLocker locker(m_CritSect);

    Close();

    CPLString szDirPath = CPLGetPath(m_sPath);
    CPLString szName = CPLGetBasename(m_sPath);
	CPLString szNewName(ClearExt(sNewName).mb_str(wxConvUTF8));

    char** papszFileList = GetFileList();
    papszFileList = CSLAddString( papszFileList, m_sPath );
    if(!papszFileList)    
    {
        if(pTrackCancel)
            pTrackCancel->PutMessage(_("No files to rename"), wxNOT_FOUND, enumGISMessageErr);
        return false;
    }

    char **papszNewFileList = NULL;

    for(int i = 0; papszFileList[i] != NULL; ++i )
    {
        CPLString szNewPath(CPLFormFilename(szDirPath, szNewName, GetExtension(papszFileList[i], szName)));
        papszNewFileList = CSLAddString(papszNewFileList, szNewPath);
        if(!RenameFile(papszFileList[i], papszNewFileList[i], pTrackCancel))
        {
            // Try to put the ones we moved back.
            for( --i; i >= 0; i-- )
                RenameFile( papszNewFileList[i], papszFileList[i]);

 			CSLDestroy( papszFileList );
			CSLDestroy( papszNewFileList );
            return false;
        }
    }

	m_sPath = CPLString(CPLFormFilename(szDirPath, szNewName, CPLGetExtension(m_sPath)));

	CSLDestroy( papszFileList );
	CSLDestroy( papszNewFileList );
	return true;
}
Ejemplo n.º 19
0
void Transition::Load( CString sBGAniDir )
{
	if( IsADirectory(sBGAniDir) && sBGAniDir.Right(1) != "/" )
		sBGAniDir += "/";

	this->RemoveAllChildren();

	m_sprTransition.Load( sBGAniDir );
	m_sprTransition->PlayCommand( "On" );
	this->AddChild( m_sprTransition );
	m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft();

	m_State = waiting;

	// load sound from file specified by ini, or use the first sound in the directory
	
	if( IsADirectory(sBGAniDir) )
	{
		IniFile ini;
		ini.ReadFile( sBGAniDir+"/BGAnimation.ini" );

		CString sSoundFileName;
		if( ini.GetValue("BGAnimation","Sound", sSoundFileName) )
		{
			FixSlashesInPlace( sSoundFileName );
			CString sPath = sBGAniDir+sSoundFileName;
			CollapsePath( sPath );
			m_sound.Load( sPath );
		}
		else
		{
			m_sound.Load( sBGAniDir );
		}
	}
	else if( GetExtension(sBGAniDir).CompareNoCase("xml") == 0 )
	{
		CString sSoundFile;
		XNode xml;
		xml.LoadFromFile( sBGAniDir );
		if( xml.GetAttrValue( "Sound", sSoundFile ) )
			m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
	}
}
Ejemplo n.º 20
0
FileType GetFileType(const ea::string& fileName)
{
    auto extension = GetExtension(fileName).to_lower();
    if (archiveExtensions_.contains(extension))
        return FTYPE_ARCHIVE;
    if (wordExtensions_.contains(extension))
        return FTYPE_WORD;
    if (codeExtensions_.contains(extension))
        return FTYPE_CODE;
    if (imagesExtensions_.contains(extension))
        return FTYPE_IMAGE;
    if (textExtensions_.contains(extension))
        return FTYPE_TEXT;
    if (audioExtensions_.contains(extension))
        return FTYPE_AUDIO;
    if (extension == "pdf")
        return FTYPE_PDF;
    return FTYPE_FILE;
}
Ejemplo n.º 21
0
bool wxGISDataset::Move(const CPLString &szDestPath, ITrackCancel* const pTrackCancel)
{
	wxCriticalSectionLocker locker(m_CritSect);

    Close();

    char** papszFileList = GetFileList();
    papszFileList = CSLAddString( papszFileList, m_sPath );
    if(!papszFileList)    
    {
        if(pTrackCancel)
            pTrackCancel->PutMessage(_("No files to move"), wxNOT_FOUND, enumGISMessageErr);
        return false;
    }

    CPLString szFileName = CPLGetBasename(GetUniqPath(m_sPath, szDestPath, CPLGetBasename(m_sPath)));

    char** papszMovedFileList = NULL;

	for(int i = 0; papszFileList[i] != NULL; ++i )
    {
		CPLString szNewDestFileName(CPLFormFilename(szDestPath, szFileName, GetExtension(papszFileList[i], szFileName)));
        papszMovedFileList = CSLAddString(papszMovedFileList, szNewDestFileName);
        if(!MoveFile(szNewDestFileName, papszFileList[i], pTrackCancel))
		{
            // Try to put the ones we moved back.
            pTrackCancel->Reset();
            for( --i; i >= 0; i-- )
                MoveFile( papszFileList[i], papszMovedFileList[i]);

			CSLDestroy( papszFileList );
			CSLDestroy( papszMovedFileList );
            return false;
		}
    }

    m_sPath = CPLFormFilename(szDestPath, CPLGetFilename(m_sPath), NULL);

	CSLDestroy( papszFileList );
	CSLDestroy( papszMovedFileList );
    return true;
}
Ejemplo n.º 22
0
void LocationDlg::OnLoadAnim( wxCommandEvent &event )
{
	wxString filter = _("Polyline Data Sources");
	filter += _T("|");
	AddType(filter, FSTRING_VTAP);
	AddType(filter, FSTRING_SHP);
	AddType(filter, FSTRING_DXF);
	AddType(filter, FSTRING_IGC);

	wxFileDialog loadFile(NULL, _("Load Animation Path"), _T(""), _T(""),
		filter, wxFD_OPEN);
	bool bResult = (loadFile.ShowModal() == wxID_OK);
	if (!bResult)
		return;

	vtAnimPath *anim;
	bool bSuccess;
	wxString str = loadFile.GetPath();
	vtString filename = (const char *) str.mb_str(wxConvUTF8);
	if (GetExtension(filename) == ".vtap")
	{
		anim = CreateAnimPath();
		bSuccess = anim->Read(filename);
	}
	else
	{
		vtFeatureLoader loader;
		vtFeatureSet *pSet = loader.LoadFrom(filename);
		if (!pSet)
			return;
		anim = CreateAnimPath();
		bSuccess = anim->CreateFromLineString(m_pSaver->GetAtProjection(), pSet);
		delete pSet;
	}
	if (bSuccess)
	{
		AppendAnimPath(anim, filename);
		RefreshAnims();
	}
	else
		delete anim;
}
Ejemplo n.º 23
0
void Urho3D::Start()
{
#ifdef ENABLE_LUA
    String extension = GetExtension(scriptFileName_).ToLower();
    if (extension != ".lua")
    {
#endif
        // Instantiate and register the AngelScript subsystem
        context_->RegisterSubsystem(new Script(context_));

        // Hold a shared pointer to the script file to make sure it is not unloaded during runtime
        scriptFile_ = context_->GetSubsystem<ResourceCache>()->GetResource<ScriptFile>(scriptFileName_);

        // If script loading is successful, proceed to main loop
        if (scriptFile_ && scriptFile_->Execute("void Start()"))
        {
            // Subscribe to script's reload event to allow live-reload of the application
            SubscribeToEvent(scriptFile_, E_RELOADSTARTED, HANDLER(Urho3D, HandleScriptReloadStarted));
            SubscribeToEvent(scriptFile_, E_RELOADFINISHED, HANDLER(Urho3D, HandleScriptReloadFinished));
            SubscribeToEvent(scriptFile_, E_RELOADFAILED, HANDLER(Urho3D, HandleScriptReloadFailed));
            return;
        }
#ifdef ENABLE_LUA
    }
    else
    {
        // Instantiate and register the Lua script subsystem
        context_->RegisterSubsystem(new LuaScript(context_));
        LuaScript* luaScript = GetSubsystem<LuaScript>();

        // If script loading is successful, proceed to main loop
        if (luaScript->ExecuteFile(scriptFileName_.CString()))
        {
            luaScript->ExecuteFunction("Start");
            return;
        }
    }
#endif

    // The script was not successfully loaded. Show the last error message and do not run the main loop
    ErrorExit();
}
Ejemplo n.º 24
0
bool BuildWindows::CheckIncludeResourceFile(const String& resourceDir, const String& fileName)
{
    // #623 BEGIN TODO: Skip files that have a converted version in the cache
    AssetDatabase* db = GetSubsystem<AssetDatabase>();
    String cachePath = db->GetCachePath();
    if (resourceDir != cachePath)
    {
        String ext = GetExtension(fileName);
        if (ext == ".jpg" || ext == ".png" || ext == ".tga")
        {
            FileSystem* fileSystem = GetSubsystem<FileSystem>();
            String compressedPath = cachePath + "DDS/" + fileName + ".dds";
            if (fileSystem->FileExists(compressedPath))
                return false;
        }
    }
    // #623 END TODO

    return BuildBase::CheckIncludeResourceFile(resourceDir, fileName);
}
Ejemplo n.º 25
0
wxString ExportPlugin::GetMask()
{
   if (!mMask.IsEmpty()) {
      return mMask;
   }

   wxString mask = GetDescription() + wxT("|");

   // Build the mask, but cater to the Mac FileDialog and put the default
   // extension at the end of the mask.
   wxString ext = GetExtension();
   wxArrayString exts = GetExtensions();
   for (size_t i = 0; i < exts.GetCount(); i++) {
      if (ext != exts[i]) {
         mask += wxT("*.") + exts[i] + wxT(";");
      }
   }

   return mask + wxT("*.") + ext;
}
Ejemplo n.º 26
0
void ImportCmd::Run()
{
    ToolSystem* tsystem = GetSubsystem<ToolSystem>();
    Project* project = tsystem->GetProject();
    String resourcePath = project->GetResourcePath();

    String ext = GetExtension(assetFilename_);

    if (ext == ".json")
    {
        Poco::File file(assetFilename_.CString());

        if (!file.exists())
        {
            Error(ToString("JSON source scene does not exist: %s", assetFilename_.CString()));
            return;
        }

        LOGRAWF("Importing JSON: %s", assetFilename_.CString());

        SharedPtr<JSONSceneImporter> jimporter;
        jimporter = new JSONSceneImporter(context_);
        jimporter->Import(assetFilename_);

        SharedPtr<JSONSceneProcess> sceneProcess;
        sceneProcess = new JSONSceneProcess(context_, jimporter);
        sceneProcess->Process(resourcePath);
        sceneProcess->Write();
    }
    else
    {
        SharedPtr<OpenAssetImporter> importer(new OpenAssetImporter(context_));
        if (importer->Load(assetFilename_))
        {
            importer->ExportModel("/Users/josh/Desktop/ExportedModel.mdl");
        }

    }

    Finished();
}
Ejemplo n.º 27
0
CString CExtensionListControl::CListItem::GetText(int subitem) const
{
    switch (subitem)
    {
    case COL_EXTENSION:
        {
            return GetExtension();
        }

    case COL_COLOR:
        {
            return _T("(color)");
        }

    case COL_BYTES:
        {
            return FormatBytes(m_record.bytes);
        }

    case COL_FILES:
        {
            return FormatCount(m_record.files);
        }

    case COL_DESCRIPTION:
        {
            return GetDescription();
        }

    case COL_BYTESPERCENT:
        {
            return GetBytesPercent();
        }

    default:
        {
            ASSERT(0);
            return wds::strEmpty;
        }
    }
}
Ejemplo n.º 28
0
void OggOpusFile::Open(CStdString& filename, fileOpenModeEnum mode, bool stereo, int sampleRate)
{
	if(m_sampleRate == 0)
	{
		m_sampleRate = sampleRate;
	}

	if(!m_filename.Equals(filename))
	{
		m_filename = filename + GetExtension();
	}
	fout = NULL;
	m_mode = mode;
	if (mode == READ)
	{
		fout = ACE_OS::fopen((PCSTR)m_filename, "rb");
	}
	else
	{
		FileRecursiveMkdir(m_filename, CONFIG.m_audioFilePermissions, CONFIG.m_audioFileOwner, CONFIG.m_audioFileGroup, CONFIG.m_audioOutputPathMcf);
		fout = ACE_OS::fopen((PCSTR)m_filename, "wb");
		if(CONFIG.m_audioFilePermissions)
		{
			FileSetPermissions(m_filename, CONFIG.m_audioFilePermissions);
		}

		if(CONFIG.m_audioFileGroup.size() && CONFIG.m_audioFileOwner.size())
		{
			FileSetOwnership(m_filename, CONFIG.m_audioFileOwner, CONFIG.m_audioFileGroup);
		}
	}
	if(!fout)
	{
		throw(CStdString("Could not open file: ") + m_filename);
	}

    Init();
    WriteHeader();
    //Close();

}
Ejemplo n.º 29
0
FileType ActorUtil::GetFileType( const RString &sPath )
{
	RString sExt = GetExtension( sPath );
	sExt.MakeLower();

	etft_cont_t::iterator conversion_entry= ExtensionToFileType.find(sExt);
	if(conversion_entry != ExtensionToFileType.end())
	{
		return conversion_entry->second;
	}
	else if(sPath.size() > 0 && sPath[sPath.size()-1] == '/')
	{
		return FT_Directory;
	}
	/* Do this last, to avoid the IsADirectory in most cases. */
	else if(IsADirectory(sPath))
	{
		return FT_Directory;
	}
	return FileType_Invalid;
}
Ejemplo n.º 30
0
bool C4ObjectInfo::Load(C4Group &hMother, const char *szEntryname)
{

	// New version
	if (SEqualNoCase(GetExtension(szEntryname),"oci"))
	{
		C4Group hChild;
		if (hChild.OpenAsChild(&hMother,szEntryname))
		{
			if (!C4ObjectInfo::Load(hChild))
				{ hChild.Close(); return false; }
			// resolve definition, if possible
			// only works in game, but is not needed in frontend or startup editing anyway
			pDef = C4Id2Def(id);
			hChild.Close();
			return true;
		}
	}

	return false;
}