BOOL isValidParameters()

in tools/ROADClassesGenerator/ROADClassesGenerator/main.m [81:106]


BOOL isValidParameters(RFArgumentResolver *cmdLineArguments) {
    if (cmdLineArguments.sourcePath.length == 0) {
        [RFConsole writeLine:@"ERROR: Path to source file was not specified"];
        return NO;
    }
    BOOL isDir;
    BOOL dirExists = [[NSFileManager defaultManager] fileExistsAtPath:cmdLineArguments.sourcePath isDirectory:&isDir];
    if (!dirExists) {
        [RFConsole writeLine:[NSString stringWithFormat:@"ERROR: Source json file not exist at path %@", cmdLineArguments.sourcePath]];
        return NO;
    }
    
    dirExists = [[NSFileManager defaultManager] fileExistsAtPath:cmdLineArguments.outputDirectoryPath isDirectory:&isDir];
    if (!dirExists) {
        [RFConsole writeLine:[NSString stringWithFormat:@"ERROR: Output directory not exist at path %@", cmdLineArguments.outputDirectoryPath]];
    }
    else if (!isDir) {
        [RFConsole writeLine:[NSString stringWithFormat:@"ERROR: Output directory is not a directory at path %@", cmdLineArguments.outputDirectoryPath]];
    }
    
    if (!isDir || !dirExists) {
        return NO;
    }
    
    return YES;
}