Advertisement
slashdemonofthesword

HaxeFileSystem

Apr 3rd, 2016
1,151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 2.89 KB | None | 0 0
  1. import sys.FileSystem;
  2. import sys.io.File;
  3.  
  4. class HaxeFileSystem
  5. {
  6.    
  7.     public static function main()
  8.     {
  9.        
  10.         var userInput:String; // Will be used to store user input
  11.         var userInputFilePath:String; // Stores user input that will be direcotyr.
  12.        
  13.         userInputFilePath = ""; // Clears it, for good luck.
  14.        
  15.         trace("Welcome to HaxeFileSystem, a program that showcase's the file system capabilites in Haxe.");
  16.         trace("This program is a Command Prompt/Terminal application however it could be expended into applications.");
  17.         trace("Without further waiting, Let's being.");
  18.        
  19.         trace("-----------------------------------------------------------------------------------------------------------");
  20.         trace("What would you like to do. Please select any of the corresponding numbers");
  21.         trace("-----------------------------------------------------------------------------------------------------------");
  22.         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 ");
  23.        
  24.         userInput = Sys.stdin().readLine(); // Prmopts user for input
  25.        
  26.         switch (userInput)
  27.         {
  28.             case "1":
  29.                 {
  30.                     trace("Remember to add the file extension at the end or else it will be a blank document.");
  31.                     userInputFilePath = Sys.stdin().readLine();
  32.                     File.write(userInputFilePath);
  33.                     userInputFilePath = ""; // Again for good luck
  34.                 }
  35.                
  36.             case "2":
  37.                 {
  38.                     trace("Remember to add file extension at the end or else Haxe withh throw an error.");
  39.                     userInputFilePath = Sys.stdin().readLine();
  40.                     FileSystem.deleteFile(userInputFilePath);
  41.                     userInputFilePath = "";
  42.                 }
  43.                
  44.             case "3":
  45.                 {
  46.                     trace("Remember to add the name of the file after you have the directory.");
  47.                     userInputFilePath = Sys.stdin().readLine();
  48.                     FileSystem.createDirectory(userInputFilePath);
  49.                     userInputFilePath = "";
  50.                 }
  51.                
  52.             case "4":
  53.                 {
  54.                     trace("Remember to add the name of the file at the end");
  55.                     userInputFilePath = Sys.stdin().readLine();
  56.                     FileSystem.deleteDirectory(userInputFilePath);
  57.                     userInputFilePath = "";
  58.                 }
  59.                
  60.             case "5":
  61.                 {
  62.                     trace("Remember the add the folder or file and it's extension");
  63.                     trace("Path of the file/folder you want to rename: ");
  64.                     userInputFilePath = Sys.stdin().readLine();
  65.                     trace("");
  66.                     trace("Path of the file/folder but with the name changed: ");
  67.                     var userInputFilePathNew:String = Sys.stdin().readLine();
  68.                     FileSystem.rename(userInputFilePath, userInputFilePathNew);
  69.                     trace("");
  70.                     trace('You have relocated from $userInputFilePath to $userInputFilePathNew');
  71.                 }
  72.                
  73.             case "6":
  74.                 {
  75.                     trace("Remember to give the file location, not the file");
  76.                     userInputFilePath = Sys.stdin().readLine();
  77.                     trace(FileSystem.readDirectory(userInputFilePath));
  78.                 }
  79.                
  80.             default:
  81.                
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement