level dw 1 search_pattern db "*.*",0 previous_dir db "..",0 starting_dir rb 64 I may add some pretty ascii later. or maybe not. that would involve a whole new level of complexity.
I've done something like this before, and if I remember right, going three directories deep made things harder. At that point, there needs to be some white space between your symbols, so you can't just repeat '|' until you get up by the start of the names.
For example, if "solidoak.svg" was a directory with its own sub-directories, you wouldn't continue the line down between those sub-directories and the root directory line, because solidoak.svg is at the end of the list it belongs to.
Cameron Cooper
>C++ Why? You almost had proper, elegant C there, and then you go fuck it up with your STDs for no reason.
What's wrong with a shebang directive at the beginning of a powershell script? Powershell is available on Linux now. Might as well make it executable...
Jeremiah Johnson
Can't post an image, it's got color. OOOOH! with Ada.Text_IO; use Ada.Text_IO; with Ada.Directories; use Ada.Directories; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with Ada.Command_Line; use Ada.Command_Line;
procedure Get_Files (Current_Directory : in String) is Current_Search : Search_Type; Dir_Entry : Directory_Entry_Type; begin Start_Search(Current_Search, Current_Directory, ""); while More_Entries(Current_Search) loop Get_Next_Entry(Current_Search, Dir_Entry); if Simple_Name(Dir_Entry) /= "." and then Simple_Name(Dir_Entry) /= ".." and then Kind(Dir_Entry) = Directory then Put(Global_Indent); Put_Line(Simple_Name(Dir_Entry)); if Length(Global_Indent) = 0 then Global_Indent := Global_Indent & "|-->"; else Global_Indent := "| " & Global_Indent; end if; Get_Files(Full_Name(Dir_Entry)); Delete(Global_Indent, 1, 4); elsif Kind(Dir_Entry) = Ordinary_File then Put(Global_Indent); Put_Line(ASCII.esc & "[94m" & Simple_Name(Dir_Entry) & ASCII.esc & "[0m"); end if; end loop; end Get_Files;
begin
Get_Files(Current_Directory);
end Filesystem;
Ian Ward
Pretty dense with no comments, but it seems alright.
;;; repeat a the given string 'n' times (define (string-repeat s n) (string-append* (build-list n (const s))))
;;; parse command line options (command-line #:args dirs ; traverse function (define (trav dir [indent 0]) (printf "~a/\n" (last (explode-path dir))) (let ([lst (directory-list dir)]) (for ([child (in-list lst)] [i (in-naturals 1)] ; skip hidden files #:unless (regexp-match #px"^\\." (path->string child))) ; build full path out of name of child (let* ([fullpath (build-path dir child)] [dir? (directory-exists? fullpath)]) ; display prefix (printf "~a~a\u2500\u2500 " (string-repeat "\u2502 " indent) (if (and (not dir?) (= i (length lst))) "\u2514" "\u251c")) ; recur if directory, or just show file name (if dir? (trav fullpath (add1 indent)) (displayln child)))))) ; call on all arguments (for-each trav (if (empty? dirs) ; or, use cd if no arguments '(".") dirs)))
Hunter Morgan
>seems alright it couldn't be cleaner, other than the necessary escape characters.
Lucas Moore
>>>pastebin.com/SYy0ywJP Now eligible for bonus points. But too long to fit in one post. Also fixed a bug where it would print a directory twice (see screenshot ) As far as I can tell, there's no way to know ahead of time if the current entry will be the last one in the directory, so I ended up storing the previous entry and adjusting the prefix as needed.
pic won't upload for some reason
Kayden Young
+1 for Lisp
Adam Scott
This is racket:
Joshua Gutierrez
std::string is far more elegant than the crap I would of had to write if it was in C.
Needing to ask the OS for directory info means I don't get to use my own dumb language. Have one in befunge instead: v 8y& 9u4%d %&^652f op$!*is$1 a2*_!1%fAg^ ov^3)(kgI93jf3
Dylan Williams
I uh either take advantage of some behavior of cfunge specifically or a use a hacky thing to get around a bug that at the very least doesn't work in pyfunge. Maybe it's cross platform. I'm a little confused about how the y command works to be honest, getting the command line args on to the stack was way trickier than I thought it would be
>wake up at 7am everday. >had really good breakfast. >then go to he libary >learn new things with lots of books and tutorials >mfw i understand everthing just so well and everyday is gettin better than the yesterday
Sebastian Collins
You're still a NEET
Lincoln Ross
no i am not a neet
Luis Brown
wagecucks BTFO
Adam Rivera
he didn't say he is self employed, from his post I would say he is a (uni?) student.
#define error(...) \ do { \ fprintf(stderr, __VA_ARGS__); \ exit(EXIT_FAILURE); \ } while (0)
int node_print(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) { if (ftwbuf->level > 0) { for (int i = 0; i < ftwbuf->level; i++) printf("| ");
if (ftwbuf->level > 0) printf("+-- "); }
size_t len = strlen(fpath) + 1; char filebuf[len];
Oops, ignore the the second if (ftwbuf->level > 0).
Changed it at the last second and forgot to remove it.
Jace Stewart
>arial not using helvetica
Jack Myers
> tree.py Folder PATH listing for volume Data G4TB Volume serial number is XXXX-XXXX N:. ├───.hg │ ├───cache │ └───store │ └───data │ └───src └───src
Nathan Sanchez
>mfw g++ doesn't support the filesystem ts yet
Landon King
that is pretty cool
Brayden Collins
not perfect but whatever
Liam Ross
...
Hudson Reed
Thanks, it's still not perfect though, suffers from the same problem mentioned here: . But at least it happens less frequently since file-search syscalls in dos always return directories before files. The only way to completely avoid that would require storing the entire tree in memory before printing, so you can iterate over it both ways and tell if the current directory has more files before recursing into a new directory.