xModders

DirManager.src

Jan 21st, 2025 (edited)
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | Gaming | 0 0
  1. isExist = function(x,y)
  2.  
  3. filePath = x + "/" + y;
  4. file = get_shell.host_computer.File(filePath);
  5.  
  6. if typeof(file) == "file" then
  7.  
  8. return true;
  9.  
  10. else
  11.  
  12. return false;
  13.  
  14. end if
  15.  
  16. end function
  17.  
  18. createFile = function(x,y,z)
  19.  
  20. if isExist(x,y) == false then
  21.  
  22. if z == "file" then
  23.  
  24. get_shell.host_computer.touch(x,y);
  25.  
  26. else if z == "folder" then
  27.  
  28. get_shell.host_computer.create_folder(x,y);
  29.  
  30. else
  31.  
  32. return "Can only create file or folder."
  33.  
  34. end if
  35.  
  36. else
  37.  
  38. return "File Already exist.";
  39.  
  40. end if
  41.  
  42. end function
  43.  
  44. contentFile = function(x,y,z)
  45.  
  46. file = get_shell.host_computer.File((x + "/" + y));
  47.  
  48. if typeof(file) == "file" then
  49.  
  50. file.set_content(z);
  51.  
  52. else
  53.  
  54. return "File not found.";
  55.  
  56. end if
  57.  
  58. end function
  59.  
  60. DirManager = function(w,x,y,z)
  61.  
  62. FileAction = w;
  63. FilePath = x;
  64. FileName = y;
  65. FileType = z;
  66.  
  67. if FileAction == "create" then
  68.  
  69. createFile(FilePath,FileName,FileType);
  70.  
  71. else if FileAction == "content" then
  72.  
  73. contentFile(FilePath,FileName,FileType);
  74.  
  75. else
  76.  
  77. return "Action provided is not available. Actions are 'create','content'";
  78.  
  79. end if
  80.  
  81. end function
Tags: Script
Advertisement
Add Comment
Please, Sign In to add comment