video ffmpeg - post review fixes

- rename OS_PATH_SEPARATOR -> PS and use in all needed places
- change function name from `open_file` to `launch_default_app`
- move `mkdir`, `rm` and `launch_default_app` helper functions to libs
- add executable_path_widget to export module if needed, not to the
preferences
- add show_status
- remove support_format
- change function name `format` to `format_string`, add comments
- replace apostrophes by quote marks
This commit is contained in:
theres
2019-01-27 02:34:01 +01:00
parent 3a129d3c4f
commit 3675f4d7cd
4 changed files with 524 additions and 463 deletions

View File

@@ -1,6 +1,7 @@
local dtutils_file = {}
local dt = require "darktable"
local ds = require "lib/dtutils.string"
local dsys = require "lib/dtutils.system"
local log = require "lib/dtutils.log"
@@ -553,5 +554,50 @@ function dtutils_file.sanitize_filename(filename)
return ds.sanitize(filename)
end
dtutils_file.libdoc.functions["mkdir"] = {
Name = [[mkdir]],
Synopsis = [[create the directory(ies) if they do not already exists]],
Usage = [[local df = require "lib/dtutils.file"
df.mkdir(path)
path - string - a directory path]],
Description = [[mkdir creates directories if not already exists. It
create whole parents subtree if needed
]],
Return_Value = [[path - string - a directory path]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_file.mkdir(path)
local mkdir_cmd = dt.configuration.running_os == "windows" and "mkdir" or "mkdir -p"
return dsys.external_command(mkdir_cmd.." "..dtutils_file.sanitize_filename(path))
end
dtutils_file.libdoc.functions["rm"] = {
Name = [[rm]],
Synopsis = [[remove file or directory]],
Usage = [[local df = require "lib/dtutils.file"
df.rm(path)
path - string - a file or directory path]],
Description = [[rm allow to recursively remove files or directories]],
Return_Value = [[path - string - a file or directory path]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_file.rm(path)
local rm_cmd = dt.configuration.running_os == "windows" and "rmdir /S /Q" or "rm -r"
return dsys.external_command(rm_cmd.." "..dtutils_file.sanitize_filename(path))
end
return dtutils_file

View File

@@ -101,4 +101,34 @@ function dtutils_system.windows_command(command)
return result
end
dtutils_system.libdoc.functions["launch_default_app"] = {
Name = [[launch_default_app]],
Synopsis = [[try to open file in default application]],
Usage = [[local dsys = require "lib/dtutils.file"
dsys.launch_default_app(path)
path - string - a file path]],
Description = [[launch_default_app allow to open file in application that is assigned as default
one in users's system for given filetype
]],
Return_Value = [[path - string - a file path]],
Limitations = [[]],
Example = [[]],
See_Also = [[]],
Reference = [[]],
License = [[]],
Copyright = [[]],
}
function dtutils_system.launch_default_app(path)
local open_cmd = "xdg-open"
if (dt.configuration.running_os == "windows") then
open_cmd = "start"
elseif (dt.configuration.running_os == "macos") then
open_cmd = "open"
end
return dtutils_system.external_command(open_cmd..' "'..path..'"')
end
return dtutils_system