Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Copyright 2014 Chauncey
- //
- // This program is free software: you can redistribute it and/or modify
- // it under the terms of the GNU Lesser General Public License as published
- // by the Free Software Foundation, either version 3 of the License, or
- // (at your option) any later version.
- //
- // This program is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU Lesser General Public License for more details.
- //
- // You should have received a copy of the GNU Lesser General Public License
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
- //
- //
- //
- //
- using System;
- using System.IO;
- using System.Collections.Generic;
- //todo: add formatting/flags
- public class LS {
- static public int Main (string[] args) {
- string path = @"";
- if (args.Length == 0) {
- path = Directory.GetCurrentDirectory();
- }
- else if (args[0] == "--help") {
- //Console.WriteLine(help);
- }
- else {
- path = args[0];
- }
- //WriteOut("\n");
- WriteOut(". ");
- WriteOut(".. ");
- getdir(path);
- WriteOut("\n");
- return 0;
- }
- public static string reverses (string a) {
- char[] input = a.ToCharArray();
- Array.Reverse(input);
- return new string(input);
- }
- static public void WriteOut (string a) {
- Console.Write(a); //make this format stuff
- }
- static public int getdir (string path) {
- string slash = (System.Environment.OSVersion.Platform == PlatformID.Win32NT) ? "\\" : "/";
- string[] fdir = Directory.GetFiles(path);
- string[] ddir = Directory.GetDirectories(path);
- List<string> list = new List<string>();
- list.AddRange(fdir);
- list.AddRange(ddir);
- string[] dir = list.ToArray();
- foreach (string key in dir) {
- string input = key;
- int index = input.LastIndexOf(slash);
- if (index != -1) {
- input = input.Substring(index+1);
- }
- WriteOut(input + " ");
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement