#########################################################################
##                                                                     ##
##  I N T E R S T E L L A R   C O N S O L E                            ##
##            Copyright (C) 2025- Misato Observatory, Wakayama, Japan  ##
##                                                                     ##
##  This software is available under the GPL (General Public License)  ##
##                                                                     ##
#########################################################################

####################################################################
##                                                                ##
##     S Y S T E M - D E P E N D E N T    P R O C E D U R E S     ##
##                                                                ##
####################################################################

#
# Get OS name
#
proc get_os_name {} {

  set os_name ""
  if { [info exists ::android] } {
    set os_name "Android"
  } elseif { [info exists ::env(OS)] } {
    set os_name $::env(OS)
  }

  if { $os_name eq "" } {
    # Check Android
    #set str_uname_r [exec -ignorestderr uname -r]
    # split a string like "6.6.30-android15-6-xxxxxxxxxxxxx"
    #set elms [split $str_uname_r "-"]
    #set len_elms [llength $elms]
    #for {set i 0} {$i < $len_elms} {incr i} {
    #  set el [string tolower [lindex $elms $i]]
    #  if { [string range $el 0 6] eq "android" } {
    #    set os_name "Android"
    #    break
    #  }
    #}
    # Linux, Darwin, etc.
    if { $os_name eq "" } {
      set os_name [exec -ignorestderr uname]
    }
  }
  if { $os_name eq "" } {
    set os_name "Unknown OS"
  }

  return $os_name

}

#
# Get Stellarium executable file
#
proc get_stellarium_executable_file {} {

  set path_ret "C:/Program Files/Stellarium/stellarium.exe"

  return $path_ret

}

#
# Get Stellarium output directory name
#
proc get_stellarium_io_directory {} {

  set path_raw $::env(HOMEDRIVE)
  append path_raw $::env(HOMEPATH)
  append path_raw "/AppData/Roaming/Stellarium"

  set path_ret [regsub -all {\\} $path_raw {/}]

  return $path_ret

}

