mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 00:43:00 +08:00
Recursive create folders in RPF explorer
This commit is contained in:
parent
88016633da
commit
8f6ac6aad6
@ -2383,16 +2383,24 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
return;//no name was provided.
|
return;//no name was provided.
|
||||||
}
|
}
|
||||||
if (!IsFilenameOk(fname)) return; //new name contains invalid char(s). don't do anything
|
|
||||||
|
|
||||||
|
var fnames = fname.Split(new[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
string cpath = (string.IsNullOrEmpty(CurrentFolder.Path) ? "" : CurrentFolder.Path + "\\");
|
|
||||||
string relpath = cpath + fname.ToLowerInvariant();
|
|
||||||
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
|
||||||
string fullpath = rootpath + relpath;
|
|
||||||
|
|
||||||
RpfDirectoryEntry newdir = null;
|
RpfDirectoryEntry newdir = null;
|
||||||
MainTreeFolder node = null;
|
MainTreeFolder node = null;
|
||||||
|
MainTreeFolder cnode = null;
|
||||||
|
string cpath = (string.IsNullOrEmpty(CurrentFolder.Path) ? "" : CurrentFolder.Path + "\\");
|
||||||
|
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
|
var csubpath = "";
|
||||||
|
|
||||||
|
foreach (var name in fnames)
|
||||||
|
{
|
||||||
|
if (!IsFilenameOk(name)) break; //new name contains invalid char(s). don't continue
|
||||||
|
|
||||||
|
csubpath += name;
|
||||||
|
|
||||||
|
string relpath = cpath + csubpath.ToLowerInvariant();
|
||||||
|
string fullpath = rootpath + relpath;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -2402,9 +2410,20 @@ namespace CodeWalker
|
|||||||
|
|
||||||
//create new directory entry in the RPF.
|
//create new directory entry in the RPF.
|
||||||
|
|
||||||
newdir = RpfFile.CreateDirectory(CurrentFolder.RpfFolder, fname);
|
newdir = RpfFile.CreateDirectory(newdir ?? CurrentFolder.RpfFolder, name);
|
||||||
|
|
||||||
node = CreateRpfDirTreeFolder(newdir, relpath, fullpath);
|
var newnode = CreateRpfDirTreeFolder(newdir, relpath, fullpath);
|
||||||
|
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
node = newnode;
|
||||||
|
cnode = newnode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cnode.AddChild(newnode);
|
||||||
|
cnode = newnode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2415,7 +2434,17 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
Directory.CreateDirectory(fullpath);
|
Directory.CreateDirectory(fullpath);
|
||||||
|
|
||||||
node = CreateRootDirTreeFolder(fname, relpath, fullpath);
|
var newnode = CreateRootDirTreeFolder(name, relpath, fullpath);
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
node = newnode;
|
||||||
|
cnode = newnode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cnode.AddChild(newnode);
|
||||||
|
cnode = newnode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -2424,6 +2453,10 @@ namespace CodeWalker
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
csubpath += "\\";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (node != null)
|
if (node != null)
|
||||||
{
|
{
|
||||||
AddNewFolderTreeNode(node);
|
AddNewFolderTreeNode(node);
|
||||||
|
Loading…
Reference in New Issue
Block a user