I've run into a case where I think that I could use an extension to the ZFile class. Or maybe I'm once again missing something. The easiest way to explain may be to show you some Java code which I would like to be able to do:
Code: Select all
int fileType=ZFile.FileType(string);
switch (fileType) {
case ZFile.DDNAME: // string is a DD name
break;
case ZFile.DSNAME: // string is a DSN
break;
case ZFile.UNIXNAME: // string is a UNIX filename
break;
}
Code: Select all
if (string.startsWith("//")) {
if (string.startsWith("DD:", 2)) {
// DD name
} else {
// DSN
}
} else {
// UNIX name
}
What brought this on is that ZFile.exists() only works on z/OS files and not UNIX files. So I need to use ZFile.exists(input_name) if input_name is a DD or DSN, but for a UNIX file, I must use java.io.exists like:
if (java.io.File.exists(new java.io.File(input_name))
but my actual desire is actually different. I want to make sure the DD name exists if it is specified, but that the DSNAME and/or UNIX file does NOT exist if that is what is passed to my routine. The first is to avoid the ZFileException, the latter two to make sure that my output does not overwrite an existing file. Doing this make my code much more difficult to read. Although, I could just encapsulate the functions myself in a method of my own writing. I guess I'm a bit lazy. And, I will grant, that the tests are not atomic with the actual creation of the output file. At present, I restrict my output to a UNIX file and use java.io.File.createNewFile() .
Or, really nice would be a ZFile.createNewFile() functionality. Of course,that would not work with a DD name. Well,unless in the case of a DD name being passed, the code would see if the DISP on the DD was NEW. Or maybe check to see if an existing file has no data in it at all.
Just some thoughts.