Options

Issue with folder creation (Operator.getParameterAsFile)

colocolo Member Posts: 236 Maven
edited November 2018 in Help
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
Tagged:

Answers

  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

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

    Regards,
    Marco
  • Options
    colocolo Member Posts: 236 Maven
    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
Sign In or Register to comment.