aboutsummaryrefslogtreecommitdiff
path: root/platform.F90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-08-08 09:18:45 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-08-08 09:18:45 -0400
commitf6a2bd488ca74881855f74f5302078526cfbd81c (patch)
tree1700d127a03dff08685660a4238cf9c8881164f4 /platform.F90
parenta6f3add98f1c02eeee9c3c4f9bda9ef6415586f9 (diff)
downloadLR-87-f6a2bd488ca74881855f74f5302078526cfbd81c.zip
LR-87-f6a2bd488ca74881855f74f5302078526cfbd81c.tar.gz
Initial work on favorites added. Probably flat-out wrong...
Diffstat (limited to 'platform.F90')
-rw-r--r--platform.F9075
1 files changed, 75 insertions, 0 deletions
diff --git a/platform.F90 b/platform.F90
new file mode 100644
index 0000000..e10ca64
--- /dev/null
+++ b/platform.F90
@@ -0,0 +1,75 @@
+module platform
+implicit none
+
+#ifdef WINDOWS
+ character, parameter::dir_sep = '\'
+#else
+ character, parameter::dir_sep = '/'
+#endif
+
+ character(*), parameter::favorites_file = "favorites.gmi"
+
+contains
+
+ subroutine get_settings_directory(dir)
+ use iso_c_binding
+ implicit none
+
+ character(*), intent(out)::dir
+#ifdef WINDOWS
+
+ interface
+ function SHGetFolderPath(hwnd, csidl, htoken, dwflags, path) bind(c, name="SHGetFolderPathA")
+ use iso_c_binding
+ type(c_ptr), value::hwnd
+ integer(kind=c_int), value::csidl
+ type(c_ptr), value::htoken
+ integer(kind=c_int32_t), value::dwflags
+ character(kind=c_char), dimension(260)::path
+ integer(kind=c_intptr_t)::SHGetFolderPath
+ end function SHGetFolderPath
+ end interface
+
+ integer(kind=c_intptr_t), parameter::S_OK = 0
+ integer(kind=c_int), parameter::CSIDL_APPDATA = 26
+
+ character(kind=c_char), dimension(260)::path
+ integer::i
+
+ if(SHGetFolderPath(c_null_ptr, CSIDL_APPDATA, c_null_ptr, 0, path) == S_OK) then
+ dir = " "
+ i = 1
+ do while(path(i) /= c_null_char .and. i < 260)
+ dir(i:i) = path(i)
+ i = i + 1
+ end do
+ else
+ Print *, "Warning: Could not access CSIDL_APPDATA"
+ call get_environment_variable("HOME", value=dir)
+ end if
+
+ if(dir(len_trim(dir):len_trim(dir)) /= dir_sep) then
+ dir = trim(dir)//dir_sep
+ end if
+ dir = trim(dir)//"LR-87"
+#else
+ call get_environment_variable("HOME", value=dir)
+ if(dir(len_trim(dir):len_trim(dir)) /= dir_sep) then
+ dir = trim(dir)//dir_sep
+ end if
+ dir = trim(dir)//".lr87"
+#endif
+
+ end subroutine get_settings_directory
+
+ subroutine get_favorites_file(filename)
+ implicit none
+
+ character(*), intent(out)::filename
+
+ call get_settings_directory(filename)
+ filename = trim(filename)//dir_sep//favorites_file
+
+ end subroutine get_favorites_file
+
+end module platform \ No newline at end of file