예제 #1
0
/*
 * FileSPVAR - build file special variables
 */
void FileSPVAR( void )
{
    char        path[FILENAME_MAX];
    char        drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT];
    int         i;

    /*
     * build path
     */
    if( CurrentFile == NULL ) {
        VarAddGlobalStr( "F", "" );
        VarAddGlobalStr( "H", "" );
        drive[0] = dir[0] = fname[0] = ext[0] = 0;
    } else {
        VarAddGlobalStr( "F", CurrentFile->name );
        VarAddGlobalStr( "H", CurrentFile->home );
        ConditionalChangeDirectory( CurrentFile->home );
        _splitpath( CurrentFile->name, drive, dir, fname, ext );
    }
    VarAddGlobalStr( "P1", dir );
    VarAddGlobalStr( "D1", drive );
    strcpy( path, drive );
    strcat( path, dir );
    i = strlen( path ) - 1;
    if( path[i] == FILE_SEP && i > 0 ) {
        path[i] = 0;
    }
    if( CurrentFile != NULL ) {
        PushDirectory( path );
        ChangeDirectory( path );
        GetCWD2( path, FILENAME_MAX );
        PopDirectory();
    } else {
        path[0] = 0;
    }
    if( path[strlen(path) - 1] == FILE_SEP ) {
        StrMerge( 2, path, fname, ext );
    } else {
        StrMerge( 3, path,FILE_SEP_STR, fname, ext );
    }
    _splitpath( path, drive, dir, fname, ext );
    VarAddGlobalStr( "D", drive );
    VarAddGlobalStr( "P", dir );
    VarAddGlobalStr( "N", fname );
    VarAddGlobalStr( "E", ext );

} /* FileSPVAR */
예제 #2
0
/*
 * pushd command
 */
INT CommandPushd (LPTSTR rest)
{
	TCHAR curPath[MAX_PATH];

	if (!_tcsncmp (rest, _T("/?"), 2))
	{
		ConOutResPuts(STRING_DIRSTACK_HELP1);
		return 0;
	}

	GetCurrentDirectory (MAX_PATH, curPath);

	if (rest[0] != _T('\0'))
	{
		if (!SetRootPath(NULL, rest))
			return 1;
	}

	return PushDirectory(curPath);
}