Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -10,6 +10,7 @@ procedure Directory_List is
function SName return String is (Simple_Name(Found));
begin
-- search directory and store it in Result, a vector of strings
Start_Search(Search, Directory => ".", Pattern =>"");
while More_Entries(Search) loop
Get_Next_Entry(Search, Found);
@ -20,9 +21,11 @@ begin
Result.Append(Name);
end if; -- ingnore filenames beginning with "."
end;
end loop; -- now Result holds the entire directory in arbitrary order
end loop; -- Result holds the entire directory in arbitrary order
Sort(Result); -- nor Result holds the directory in proper order
Sort(Result); -- Result holds the directory in proper order
-- print Result
for I in Result.First_Index .. Result.Last_Index loop
Put_Line(Result.Element(I));
end loop;

View file

@ -0,0 +1,17 @@
#include <iostream>
#include <set>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
int main(void)
{
fs::path p(fs::current_path());
std::set<std::string> tree;
for (auto it = fs::directory_iterator(p); it != fs::directory_iterator(); ++it)
tree.insert(it->path().filename().native());
for (auto entry : tree)
std::cout << entry << '\n';
}

View file

@ -0,0 +1,4 @@
<?php
foreach(scandir('.') as $fileName){
echo $fileName."\n";
}

View file

@ -0,0 +1,11 @@
Program ls; {To list the names of all files/directories in the current directory.}
Uses DOS;
var DirInfo: SearchRec; {Predefined. See page 403 of the Turbo Pascal 4 manual.}
BEGIN
FindFirst('*.*',AnyFile,DirInfo); {AnyFile means any file name OR directory name.}
While DOSerror = 0 do {Result of FindFirst/Next not being a function, damnit.}
begin
WriteLn(DirInfo.Name);
FindNext(DirInfo);
end;
END.

View file

@ -1,17 +1,24 @@
use std::os;
use std::io::fs;
use std::{env, fmt, fs, process};
use std::io::{self, Write};
use std::path::Path;
fn main() {
let cwd = os::getcwd();
let info = fs::readdir(&cwd).unwrap();
let mut filenames = Vec::new();
for entry in info.iter() {
filenames.push(entry.filename_str().unwrap());
}
filenames.sort();
for filename in filenames.iter() {
println!("{}", filename);
}
let cur = env::current_dir().unwrap_or_else(|e| exit_err(e, 1));
let arg = env::args().nth(1);
print_files(arg.as_ref().map_or(cur.as_path(), |p| Path::new(p)))
.unwrap_or_else(|e| exit_err(e, 2));
}
#[inline]
fn print_files(path: &Path) -> io::Result<()> {
for x in try!(fs::read_dir(path)) {
println!("{}", try!(x).file_name().to_string_lossy());
}
Ok(())
}
#[inline]
fn exit_err<T>(msg: T, code: i32) -> ! where T: fmt::Display {
writeln!(&mut io::stderr(), "{}", msg).expect("Could not write to stderr");
process::exit(code)
}