Changeset 13697 in josm
- Timestamp:
- 2018-05-01T21:45:53+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/WindowsShortcut.java
r13692 r13697 7 7 import java.io.IOException; 8 8 import java.io.InputStream; 9 import java.nio.charset.StandardCharsets; 9 10 import java.text.ParseException; 11 import java.util.Locale; 10 12 11 13 /** … … 46 48 try (InputStream fis = new FileInputStream(file)) { 47 49 isPotentiallyValid = file.isFile() 48 && file.getName().toLowerCase().endsWith(".lnk") 50 && file.getName().toLowerCase(Locale.ENGLISH).endsWith(".lnk") 49 51 && fis.available() >= minimum_length 50 52 && isMagicPresent(getBytes(fis, 32)); … … 142 144 143 145 // get the file attributes byte 144 final int file _atts_offset = 0x18;145 byte file _atts = link[file_atts_offset];146 byte is _dir_mask = (byte) 0x10;147 if ((file _atts & is_dir_mask) > 0) {146 final int fileAttsOffset = 0x18; 147 byte fileAtts = link[fileAttsOffset]; 148 byte isDirMask = (byte) 0x10; 149 if ((fileAtts & isDirMask) > 0) { 148 150 isDirectory = true; 149 151 } else { … … 152 154 153 155 // if the shell settings are present, skip them 154 final int shell _offset = 0x4c;155 final byte has _shell_mask = (byte) 0x01;156 int shell _len = 0;157 if ((flags & has _shell_mask) > 0) {156 final int shellOffset = 0x4c; 157 final byte hasShellMask = (byte) 0x01; 158 int shellLen = 0; 159 if ((flags & hasShellMask) > 0) { 158 160 // the plus 2 accounts for the length marker itself 159 shell _len = bytesToWord(link, shell_offset) + 2;161 shellLen = bytesToWord(link, shellOffset) + 2; 160 162 } 161 163 162 164 // get to the file settings 163 int file _start = 0x4c + shell_len;164 165 final int file _location_info_flag_offset_offset = 0x08;166 int file _location_info_flag = link[file_start + file_location_info_flag_offset_offset];167 isLocal = (file _location_info_flag & 2) == 0;165 int fileStart = 0x4c + shellLen; 166 167 final int fileLocationInfoFlagOffsetOffset = 0x08; 168 int fileLocationInfoFlag = link[fileStart + fileLocationInfoFlagOffsetOffset]; 169 isLocal = (fileLocationInfoFlag & 2) == 0; 168 170 // get the local volume and local system values 169 //final int localVolumeTable_offset_offset = 0x0C; 170 final int basename_offset_offset = 0x10; 171 final int networkVolumeTable_offset_offset = 0x14; 172 final int finalname_offset_offset = 0x18; 173 int finalname_offset = link[file_start + finalname_offset_offset] + file_start; 174 String finalname = getNullDelimitedString(link, finalname_offset); 171 final int basenameOffsetOffset = 0x10; 172 final int networkVolumeTableOffsetOffset = 0x14; 173 final int finalnameOffsetOffset = 0x18; 174 int finalnameOffset = link[fileStart + finalnameOffsetOffset] + fileStart; 175 String finalname = getNullDelimitedString(link, finalnameOffset); 175 176 if (isLocal) { 176 int basename _offset = link[file_start + basename_offset_offset] + file_start;177 String basename = getNullDelimitedString(link, basename _offset);177 int basenameOffset = link[fileStart + basenameOffsetOffset] + fileStart; 178 String basename = getNullDelimitedString(link, basenameOffset); 178 179 realFile = basename + finalname; 179 180 } else { 180 int networkVolumeTable _offset = link[file_start + networkVolumeTable_offset_offset] + file_start;181 int shareName _offset_offset = 0x08;182 int shareName _offset = link[networkVolumeTable_offset + shareName_offset_offset]183 + networkVolumeTable _offset;184 String shareName = getNullDelimitedString(link, shareName _offset);181 int networkVolumeTableOffset = link[fileStart + networkVolumeTableOffsetOffset] + fileStart; 182 int shareNameOffsetOffset = 0x08; 183 int shareNameOffset = link[networkVolumeTableOffset + shareNameOffsetOffset] 184 + networkVolumeTableOffset; 185 String shareName = getNullDelimitedString(link, shareNameOffset); 185 186 realFile = shareName + "\\" + finalname; 186 187 } … … 201 202 len++; 202 203 } 203 return new String(bytes, off, len); 204 return new String(bytes, off, len, StandardCharsets.UTF_8); 204 205 } 205 206
Note:
See TracChangeset
for help on using the changeset viewer.