コード例 #1
0
ファイル: fileutil.cpp プロジェクト: gkathire/wxVCL
/* ------------------------------------------------------------------------------
 function GetTempFilename(const Directory, Prefix: string): string;
 ------------------------------------------------------------------------------ */
wxString GetTempFilename(wxString const & Directory, wxString const & Prefix)
{
	wxString result;
	int i;
	wxString CurPath;

	CurPath = AppendPathDelim(Directory) + Prefix;
	i = 1;
	do
	{
		result = CurPath + IntToStr(i) + ".tmp";
		if (!FileExists(result))
			return result;
		++i;
	}
	while (!(false));
	return result;
}
コード例 #2
0
void *OpenSrcFile( cue_handle *ch )
{
    void        *hndl;
    char_ring   *path;
    char        *p;
    char        *d;
    char        *rem_name;
    bool        used_star;
    unsigned    len;
    char        *buff;

    len = CueFile( ch, NULL, 0 ) + 1;
    _AllocA( buff, len );
    CueFile( ch, buff, len );
    hndl = FOpenSource( buff, CueMod( ch ), CueFileId( ch ) );
    if( hndl != NULL ) return( hndl );
    for( path = SrcSpec; path != NULL; path = path->next ) {
        used_star = FALSE;
        d = TxtBuff;
        for( p = path->name; *p != '\0'; ++p ) {
            if( *p == '*' ) {
                used_star = TRUE;
                d += ModName( CueMod( ch ), d, TXT_LEN );
            } else {
                *d++ = *p;
            }
        }
        *d = NULLCHAR;
        if( !used_star ) {
            #if 0
                /*
                    John can't remember why he put this code in, and it
                    screws up when the user sets a source path of ".".
                    If we find some case where it's required, we'll have to
                    think harder about things.
                */
            if( *ExtPointer( TxtBuff, 0 ) != '\0' ) {
                *SkipPathInfo( TxtBuff, 0 ) = '\0';
            }
            #endif
            d = AppendPathDelim( TxtBuff, 0 );
            if( !IsAbsolutePath( buff ) ) {
                StrCopy( buff, d );
                hndl = FOpenSource( TxtBuff, CueMod( ch ), CueFileId( ch ) );
                if( hndl != NULL ) return( hndl );
            }
            /*
                We have a small problem here. We want to strip off the
                path information for the source file name, but we don't
                know if the file was compiled on the local system or the
                remote one. We'll kludge things by doing a local skip
                and then a remote one and seeing who takes off the most stuff.
                Don't even think about the case where the file has been
                compiled on a third, different type of file system.
            */
            p = SkipPathInfo( buff, OP_LOCAL );
            rem_name = SkipPathInfo( buff, OP_REMOTE );
            if( rem_name > p ) p = rem_name;
            d = StrCopy( p, d );
            *d = NULLCHAR;
        }
        hndl = FOpenSource( TxtBuff, CueMod( ch ), CueFileId( ch ) );
        if( hndl != NULL ) return( hndl );
    }
    return( NULL );
}