Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys.FileSystem;
- import sys.io.File;
- class HaxeFileSystem
- {
- public static function main()
- {
- var userInput:String; // Will be used to store user input
- var userInputFilePath:String; // Stores user input that will be direcotyr.
- userInputFilePath = ""; // Clears it, for good luck.
- trace("Welcome to HaxeFileSystem, a program that showcase's the file system capabilites in Haxe.");
- trace("This program is a Command Prompt/Terminal application however it could be expended into applications.");
- trace("Without further waiting, Let's being.");
- trace("-----------------------------------------------------------------------------------------------------------");
- trace("What would you like to do. Please select any of the corresponding numbers");
- trace("-----------------------------------------------------------------------------------------------------------");
- trace("\n \n 1. Create File \n 2. Delete File \n 3. Create Directory \n 4. Delete Directory \n 5. Rename Folder or File \n 6. Files in current directory ");
- userInput = Sys.stdin().readLine(); // Prmopts user for input
- switch (userInput)
- {
- case "1":
- {
- trace("Remember to add the file extension at the end or else it will be a blank document.");
- userInputFilePath = Sys.stdin().readLine();
- File.write(userInputFilePath);
- userInputFilePath = ""; // Again for good luck
- }
- case "2":
- {
- trace("Remember to add file extension at the end or else Haxe withh throw an error.");
- userInputFilePath = Sys.stdin().readLine();
- FileSystem.deleteFile(userInputFilePath);
- userInputFilePath = "";
- }
- case "3":
- {
- trace("Remember to add the name of the file after you have the directory.");
- userInputFilePath = Sys.stdin().readLine();
- FileSystem.createDirectory(userInputFilePath);
- userInputFilePath = "";
- }
- case "4":
- {
- trace("Remember to add the name of the file at the end");
- userInputFilePath = Sys.stdin().readLine();
- FileSystem.deleteDirectory(userInputFilePath);
- userInputFilePath = "";
- }
- case "5":
- {
- trace("Remember the add the folder or file and it's extension");
- trace("Path of the file/folder you want to rename: ");
- userInputFilePath = Sys.stdin().readLine();
- trace("");
- trace("Path of the file/folder but with the name changed: ");
- var userInputFilePathNew:String = Sys.stdin().readLine();
- FileSystem.rename(userInputFilePath, userInputFilePathNew);
- trace("");
- trace('You have relocated from $userInputFilePath to $userInputFilePathNew');
- }
- case "6":
- {
- trace("Remember to give the file location, not the file");
- userInputFilePath = Sys.stdin().readLine();
- trace(FileSystem.readDirectory(userInputFilePath));
- }
- default:
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement