// Copyright (c) 2005-2007 Andre Merzky (andre@merzky.net) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include "shell.hpp" // print a list of entries in the curent directory. // resolve symbolic links, and mark directories with / void shell::c_ls (std::string args) { // get the list std::vector entries = cwd_.list (); // iterate over children for ( std::size_t i = 0; i < entries.size (); ++i ) { // check if child is directory... if ( cwd_.is_dir (entries[i]) ) { std::cout << " " << entries[i] << "/" << std::endl; } // ...or if child is link... else if ( cwd_.is_link (entries[i]) ) { std::cout << " " << entries[i] << " -> " << cwd_.read_link (entries[i]) << std::endl; } // ...or just a file else { std::cout << " " << entries[i] << std::endl; } } // that it! return; }