mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-31 07:18:25 +02:00
[ui] add string <--> file representation convertors
* convenient methods to conform strings to Qt file reprensentation using the "file:/" protocol prefix * use those methodes when manipulating files
This commit is contained in:
parent
62726b4663
commit
2cdc83f06f
7 changed files with 38 additions and 6 deletions
|
@ -22,3 +22,29 @@ function extension(path) {
|
|||
function isFile(path) {
|
||||
return extension(path) !== ""
|
||||
}
|
||||
|
||||
/// Conform 'path' to the Qt file representation relying on "file:" protocol prefix
|
||||
function stringToFile(path) {
|
||||
// already containing the file protocol
|
||||
if(path.startsWith("file:"))
|
||||
return path
|
||||
// network path
|
||||
if(path.startsWith("//"))
|
||||
return "file:" + path
|
||||
// assumed local path
|
||||
if(path.trim() == "")
|
||||
return ""
|
||||
return "file:/" + path
|
||||
}
|
||||
|
||||
/// Remove any "file:" protocol prefix from 'path'
|
||||
function fileToString(path)
|
||||
{
|
||||
// local path
|
||||
if(path.startsWith("file:///"))
|
||||
return path.replace("file:///", "")
|
||||
// network path
|
||||
else if(path.startsWith("file://"))
|
||||
return path.replace("file://", "")
|
||||
return path
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue