-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fixes #13274: Allow cygwin-paths on Windows #13297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kvitorr
wants to merge
19
commits into
JabRef:main
Choose a base branch
from
kvitorr:fix-for-issue-13274
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
382071f
feat: add method to convert Cygwin-style paths to Windows format
kvitorr 93087c9
feat: apply the convertCygwinPathToWinds on the path to prevent the I…
kvitorr 568bb34
Merge branch 'main' into fix-for-issue-13274
kvitorr 2f87d70
fix: remove FileUtil method
kvitorr 0f5cce4
Merge branch 'fix-for-issue-13274' of https://github.com/kvitorr/jabr…
kvitorr c343086
feat: add Cygwin file path /mtn/
kvitorr 773a4eb
feat: add test to Cygwin file path /mtn/
kvitorr 2334c9e
feat: add entry on CHANGELOG.md and weave the method into JabKit.
kvitorr 37c6203
feat: remove convertCygwinPathToWindows
kvitorr 19d92f3
feat: create converters and add new package to java modules
kvitorr e6aea3b
feat: apply converters to --inputs and --outputs
kvitorr 025a2eb
style: remove blank space
kvitorr 70cc464
Merge branch 'JabRef:main' into fix-for-issue-13274
kvitorr 249f38f
feat: change the DataType from String and File to Path
kvitorr 5241f3c
feat: remove code duplication
kvitorr 385ab81
fix: correct the style
kvitorr 2c40476
feat: create a new method to remove code duplication, create constant…
kvitorr fde43a6
feat: correct the unit tests to the changes made in the class
kvitorr 35a84ec
Merge branch 'fix-for-issue-13274' of https://github.com/kvitorr/jabr…
kvitorr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
import org.jabref.logic.FilePreferences; | ||
import org.jabref.logic.citationkeypattern.BracketedPattern; | ||
import org.jabref.logic.layout.format.RemoveLatexCommandsFormatter; | ||
import org.jabref.logic.os.OS; | ||
import org.jabref.logic.util.StandardFileType; | ||
import org.jabref.model.database.BibDatabase; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
|
@@ -589,4 +590,39 @@ public static String shortenFileName(String fileName, Integer maxLength) { | |
public static boolean isCharLegal(char c) { | ||
return Arrays.binarySearch(ILLEGAL_CHARS, c) < 0; | ||
} | ||
|
||
/// Converts a Cygwin-style file path to a Windows-style path if the operating system is Windows. | ||
/// | ||
/// Supported formats: | ||
/// - /cygdrive/c/Users/... → C:\Users\... | ||
/// - /mnt/c/Users/... → C:\Users\... | ||
/// - /c/Users/... → C:\Users\... | ||
/// | ||
/// @param filePath the input file path | ||
/// @return the converted path if running on Windows and path is in Cygwin format; otherwise, returns the original path | ||
public static String convertCygwinPathToWindows(String filePath) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return Path object |
||
if (!OS.WINDOWS || filePath == null) { | ||
return filePath; | ||
} | ||
|
||
if (filePath.startsWith("/mnt/") && filePath.length() > 5) { | ||
String driveLetter = filePath.substring(5, 6).toUpperCase(); | ||
String path = filePath.substring(6).replace("/", "\\\\"); | ||
return driveLetter + ":" + path; | ||
} | ||
|
||
if (filePath.startsWith("/cygdrive/") && filePath.length() > 10) { | ||
String driveLetter = filePath.substring(10, 11).toUpperCase(); | ||
String path = filePath.substring(11).replace("/", "\\\\"); | ||
return driveLetter + ":" + path; | ||
} | ||
|
||
if (filePath.matches("^/[a-zA-Z]/.*")) { | ||
String driveLetter = filePath.substring(1, 2).toUpperCase(); | ||
String path = filePath.substring(2).replace("/", "\\\\"); | ||
return driveLetter + ":" + path; | ||
} | ||
|
||
return filePath; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add something like "plainly converted if on non-Windows"