Created
June 19, 2023 13:56
-
-
Save earnhardt3rd/08ba150cc12ade8891f902c755159c5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'getopts.pl'; | |
| Getopts('m:d:t'); | |
| my $MODE = uc($opt_m) || ""; | |
| my $DEBUG = $opt_d || 0; | |
| if (defined $opt_t) { my %TEST = &File();} | |
| 1; | |
| sub File { | |
| ########################################################################### | |
| #REMC# File -- return file portion of pathname (either ".../..." or "...\...") | |
| #REMC# arg0 = string to be processed | |
| my $ARG = $_[0]||""; | |
| if ($ARG eq "") {return;} | |
| $ARG =~ s!^.*\\!!; | |
| $ARG =~ s!^.*/!!; | |
| return $ARG; | |
| } | |
| sub buildPath { | |
| ########################################################################### | |
| #REMS# buildPath() -- Checks Path and Make sure Dir tree exists | |
| #REMS# Return: N/A | |
| my $PATH = $_[0] || ""; | |
| print " buildPath($PATH)\n" if $DEBUG >0; | |
| if ($PATH eq "") {return;} | |
| $PATH =~ s/\\/\//g; | |
| $PATH =~ s/\\\\/\//g; | |
| my @TMP_STR = split('/',$PATH); | |
| my $tree="/"; | |
| if ($^O =~ /Win/) { | |
| $tree = $TMP_STR[0]; | |
| for (my $bi=1;$bi<=scalar(@TMP_STR)-1 ;$bi++) { | |
| next if $TMP_STR[$bi] eq ""; | |
| $tree = $tree . "/" . $TMP_STR[$bi]; | |
| if (! -d $tree) {mkdir $tree;} | |
| } | |
| }else { | |
| $tree = "/"; | |
| for (my $pi=0;$pi<=scalar(@TMP_STR)-1 ;$pi++) { | |
| next if $TMP_STR[$pi] eq ""; | |
| $tree = $tree . "/" . $TMP_STR[$pi]; | |
| if (! -d $tree) { | |
| mkdir $tree, 0777; | |
| my $mt = `/bin/chmod 777 $tree 2>&1`; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment