"Fossies" - the Fresh Open Source Software Archive

Member "stella-6.0.2/src/unix/OSystemUNIX.cxx" (11 Oct 2019, 1772 Bytes) of package /linux/privat/stella-6.0.2-src.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "OSystemUNIX.cxx" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.0.1_vs_6.0.2.

    1 //============================================================================
    2 //
    3 //   SSSS    tt          lll  lll
    4 //  SS  SS   tt           ll   ll
    5 //  SS     tttttt  eeee   ll   ll   aaaa
    6 //   SSSS    tt   ee  ee  ll   ll      aa
    7 //      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
    8 //  SS  SS   tt   ee      ll   ll  aa  aa
    9 //   SSSS     ttt  eeeee llll llll  aaaaa
   10 //
   11 // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
   12 // and the Stella Team
   13 //
   14 // See the file "License.txt" for information on usage and redistribution of
   15 // this file, and for a DISCLAIMER OF ALL WARRANTIES.
   16 //============================================================================
   17 
   18 #include <cstdlib>
   19 
   20 #include "FSNode.hxx"
   21 #include "Version.hxx"
   22 #include "OSystemUNIX.hxx"
   23 
   24 /**
   25   Each derived class is responsible for calling the following methods
   26   in its constructor:
   27 
   28   setBaseDir()
   29   setConfigFile()
   30 
   31   See OSystem.hxx for a further explanation
   32 */
   33 
   34 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   35 OSystemUNIX::OSystemUNIX()
   36   : OSystem()
   37 {
   38   // Use XDG_CONFIG_HOME if defined, otherwise use the default
   39   const char* configDir = getenv("XDG_CONFIG_HOME");
   40   if(configDir == nullptr)  configDir = "~/.config";
   41 
   42   string stellaDir = string(configDir) + "/stella";
   43   setBaseDir(stellaDir);
   44 
   45   // (Currently) non-documented alternative for using version-specific
   46   // config file
   47   ostringstream buf;
   48   buf << stellaDir << "/stellarc" << "-" << STELLA_VERSION;
   49 
   50   // Use version-specific config file only if it already exists
   51   FilesystemNode altConfigFile(buf.str());
   52   if(altConfigFile.exists() && altConfigFile.isWritable())
   53     setConfigFile(altConfigFile.getPath());
   54   else
   55     setConfigFile(stellaDir + "/stellarc");
   56 }