Re: specialFolderPaths("documents") returns empty string on linux LXLE
Posted: Sun Feb 10, 2019 2:39 pm
I did indeed; fixed.
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
No worries; being mistaken for a long-standing member w/ high post count and useful info is a compliment for a new poster (I hope...). So thanks yourself, FourthWorld.
Code: Select all
function specialFolderPathTMM pGenericName
# below line is the version you need if your dev environment *is* linux
#if the environment is "linux" or the environment is "development" then
if the environment is "linux" then
put specialFolderPath(pGenericName) into tPath
if the result is "folder not found" or tPath is nothing or pGenericName is "desktop" then
# verify xdg utility exists and is responsive first
if not (xdgGetPath("") ends with "not found") then
put xdgGetPath(pGenericName) into tPath
end if
end if
else
put specialFolderPath(pGenericName) into tPath
end if
return tPath
end specialFolderPathTMM
function xdgGetPath pCommonFolderName
# get common user directory paths on Linux.
# BEHAVIOR UNDEFINED ON NON-LINUX; it could just as easily cook your goldfish
# with a weasel patty on the side as produce usable output in those other OSes
# (depends on weasel patty patch status in posix sub-system).
# as of 2019 feb 10, common linux user folder names supported by xdg-user-dir are:
# DESKTOP, DOWNLOAD, DOCUMENTS, VIDEOS, PICTURES, MUSIC,
# PUBLICSHARE, TEMPLATES
# xdg-user-dir should be on any linux distro that uses systemd as a system manager,
# plus possibly others.
# If xdg-user-dir is not on the system, you'll get an error message in the return,
# which should end with "not found".
# If the folder name submitted is not valid or not defined, you just get
# the user folder by default.
put shell("xdg-user-dir " & toUpper(pCommonFolderName)) into tShellMessage
replace return with empty in tShellMessage
return tShellMessage
end xdgGetPath
Unfortunately, he mistook you for me, not Klaus, so your out of luck thereslowmaker wrote: Sun Feb 10, 2019 6:49 pm No worries; being mistaken for a long-standing member w/ high post count and useful info is a compliment for a new poster (I hope...).
Not so much different from other languages as you might think, and code reuse is always a good thing imho. The nice thing is, if you really wanted, you could stick *all* (although I don't) your go to code into one stack and that is your 'library'.slowmaker wrote: Sun Feb 10, 2019 6:49 pm This might make more sense as a (tiny, tiny) library, but I'm still so new to livecode I don't even know what livecode's equivalent of libraries, header files, classes, etc. are. So copy-and-paste functions it shall be.