dired.cc
/*
** dired - Edit the given directory. We must have read and execute
**         permission to edit a directory; calling routines must
**         guarantee this.
*/
Edit the given directory. We must have read and execute
permission to edit a directory; calling routines must
guarantee this.
Edit the given directory . We must have read and execute permission to edit a directory ; calling routines must guarantee this .
void dired(const char *dirname)
{
    if (chdir(dirname) < 0)
        error("File %s, line %d: couldn't chdir() to `%s'",
              __FILE__, __LINE__, dirname);
    char *fullname = current_directory();
    if (fullname == 0)
        error("File %s, line %d: current_directory() failed on `%s'.",
              __FILE__, __LINE__, dirname);
    DirList *dir_list = get_directory_listing(fullname);
    if (dir_list == 0)
        error("File %s, line %d: couldn't read directory `%s'",
              __FILE__, __LINE__, fullname);
     We track the CWD and PWD variables, if they\'re defined, so that
     applications such as emacs which use them will work properly.
    if (getenv("CWD"))
    {
        static String str;
        static String ostr;
        str = String("CWD=") + fullname;
        if (putenv(str) < 0)
            error("File %s, line %d: putenv(%s) failed.",
                  __FILE__, __LINE__, fullname);
        ostr = str;
    }
    if (getenv("PWD"))
    {
        static String str;
        static String ostr;
        str = String("PWD=") + fullname;
        if (putenv(str) < 0)
            error("File %s, line %d: putenv(%s) failed.",
                  __FILE__, __LINE__, fullname);
        ostr = str;
    }
    dir_stack->push(dir_list);
    initial_listing(dir_list);
    update_modeline(modeline_prefix, fullname);
    dir_list->saveYXPos(0, goal_column(dir_list));
    if (dir_list->currLine()->length() > columns())    
        leftshift_current_line(dir_list);
    else
        move_cursor(dir_list->savedYPos(), dir_list->savedXPos());
    synch_display();
    read_commands(dir_list);   main command loop
}
void dired ( const char * dirname ) { if ( chdir ( dirname ) < 0 ) error ( " " , __FILE__ , __LINE__ , dirname ) ; char * fullname = current_directory ( ) ; if ( fullname == 0 ) error ( " " , __FILE__ , __LINE__ , dirname ) ; DirList * dir_list = get_directory_listing ( fullname ) ; if ( dir_list == 0 ) error ( " " , __FILE__ , __LINE__ , fullname ) ; if ( getenv ( " " ) ) { static String str ; static String ostr ; str = String ( " " ) + fullname ; if ( putenv ( str ) < 0 ) error ( " " , __FILE__ , __LINE__ , fullname ) ; ostr = str ; } if ( getenv ( " " ) ) { static String str ; static String ostr ; str = String ( " " ) + fullname ; if ( putenv ( str ) < 0 ) error ( " " , __FILE__ , __LINE__ , fullname ) ; ostr = str ; } dir_stack -> push ( dir_list ) ; initial_listing ( dir_list ) ; update_modeline ( modeline_prefix , fullname ) ; dir_list -> saveYXPos ( 0 , goal_column ( dir_list ) ) ; if ( dir_list -> currLine ( ) -> length ( ) > columns ( ) ) leftshift_current_line ( dir_list ) ; else move_cursor ( dir_list -> savedYPos ( ) , dir_list -> savedXPos ( ) ) ; synch_display ( ) ; read_commands ( dir_list ) ; }
dired - Edit the given directory.
dired - Edit the given directory .
// // We track the CWD and PWD variables, if they\'re defined, so that // applications such as emacs which use them will work properly. // // main command loop