Changeset 13691 in josm


Ignore:
Timestamp:
2018-05-01T14:54:01+02:00 (4 weeks ago)
Author:
Don-vip
Message:

fix #16243 - load files via Windows shortcut files (*.lnk)

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java

    r12894 r13691  
    134134            for (final File file : files) {
    135135                if (file.exists()) {
    136                     this.files.add(file);
     136                    this.files.add(Main.platform.resolveFileLink(file));
    137137                } else if (file.getParentFile() != null) {
    138138                    // try to guess an extension using the specified fileFilter
  • trunk/src/org/openstreetmap/josm/tools/PlatformHook.java

    r13647 r13691  
    358358        // To be implemented if needed
    359359    }
     360
     361    /**
     362     * Resolves a file link to its destination file.
     363     * @param file file (link or regular file)
     364     * @return destination file in case of a file link, file if regular
     365     * @since 13691
     366     */
     367    default File resolveFileLink(File file) {
     368        // Override if needed
     369        return file;
     370    }
    360371}
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookWindows.java

    r13647 r13691  
    3434import java.io.BufferedWriter;
    3535import java.io.File;
     36import java.io.FileNotFoundException;
    3637import java.io.IOException;
    3738import java.io.InputStream;
     
    8081import org.openstreetmap.josm.io.CertificateAmendment.NativeCertAmend;
    8182import org.openstreetmap.josm.spi.preferences.Config;
     83
     84import sun.awt.shell.Win32ShellFolderManager2;
    8285
    8386/**
     
    767770        return null;
    768771    }
     772
     773    @Override
     774    public File resolveFileLink(File file) {
     775        if (file.getName().endsWith(".lnk")) {
     776            try {
     777                return new Win32ShellFolderManager2().createShellFolder(file).getLinkLocation();
     778            } catch (FileNotFoundException e) {
     779                Logging.error(e);
     780            }
     781        }
     782        return file;
     783    }
    769784}
Note: See TracChangeset for help on using the changeset viewer.