Issue with folder creation (Operator.getParameterAsFile)

colo
colo New Altair Community Member
edited November 5 in Community Q&A
Hi,

I was just wondering, why the web crawler doesn't automatically generate folders required for the specified output location.

CrawlerOperator calls the method getParameterAsFile(String key, boolean createMissingDirectories) with the second parameter set to true. Having a look at the method from class Operator revealed the problem:

public java.io.File getParameterAsFile(String key, boolean createMissingDirectories) throws UndefinedParameterError {
        String fileName = getParameter(key);
        ...
        if (process != null) {
            File result = process.resolveFileName(fileName);
            if (createMissingDirectories) {
                if (result.isDirectory()) {
                    result.mkdirs();
                } else {
                    File parent = result.getParentFile();
                    if (parent != null)
                        parent.mkdirs();
                }
            }
            return result;
        }
Since the directory is not existing at the time where this code starts being executed, result.isDirectory() will always return false (this is at least the case on my Windows machine). As soon as the directory exists, it is correctly recognized as directory, but that doesn't help much in case where I want it to be created.

I will solve this with a temporary workaround for now. But if you can confirm the issue, you probably might want to fix this.

Best regards
Matthias

Answers

  • Marco_Boeck
    Marco_Boeck New Altair Community Member
    Hi,

    I'm afraid I have to ask you again to file a bug report on the issue..

    Regards,
    Marco
  • colo
    colo New Altair Community Member
    Hi Marco,

    last time your answer was much more appreciated ;) I created all the bugs you asked for.

    I'm wondering about my chance of becoming "Bug Filer of the Week"... there are four up to now, don't know if this will be enough :D

    Regards
    Matthias