-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRemoveAllSuperFileLogicalFiles.ecl
34 lines (32 loc) · 1.26 KB
/
RemoveAllSuperFileLogicalFiles.ecl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
IMPORT Std;
/***
* Removes all logical subfiles from a superfile, leaving any
* sub-superfiles intact.
*
* @param superfilePath The path to the superfile
* @param delete If TRUE, physically delete the logical subfiles;
* should not be TRUE if dealing with foreign subfiles
* or files that are owned by more than one superfile;
* OPTIONAL, defaults to FALSE
*
* @return An action that performs the removal
*
* Origin: https://github.com/hpccsystems-solutions-lab/Useful_ECL
*/
EXPORT RemoveAllSuperFileLogicalFiles(STRING superfilePath, BOOLEAN delete = FALSE) := FUNCTION
subfilesToDelete := PROJECT
(
NOTHOR(Std.File.SuperFileContents(superfilePath, TRUE)),
TRANSFORM
(
{
STRING owner,
STRING subfile
},
SELF.subfile := '~' + LEFT.name,
SELF.owner := '~' + Std.File.LogicalFileSuperOwners(SELF.subfile)[1].name
)
);
removeSubfilesAction := NOTHOR(APPLY(subfilesToDelete, Std.File.RemoveSuperFile(owner, subfile, del := delete)));
RETURN removeSubfilesAction;
END;