<commit_before>/*
 * ServerOptions.cpp
 *
 * Copyright (C) 2009-11 by RStudio, Inc.
 *
 * This program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include <server/ServerOptions.hpp>

#include <core/ProgramStatus.hpp>
#include <core/ProgramOptions.hpp>
#include <core/FilePath.hpp>

#include <core/system/System.hpp>

#include <server/util/system/System.hpp>
#include <server/util/system/User.hpp>

using namespace core ;

namespace server {

namespace {

const char * const kDefaultProgramUser = "rstudio-server";

void resolvePath(const FilePath& installPath, std::string* pPath)
{
   *pPath = installPath.complete(*pPath).absolutePath();
}


} // anonymous namespace

Options& options()
{
   static Options instance ;
   return instance ;
}

ProgramStatus Options::read(int argc, char * const argv[])
{
   using namespace boost::program_options ;

   // compute install path
   FilePath installPath;
   Error error = core::system::installPath("..", argc, argv, &installPath);
   if (error)
   {
      LOG_ERROR_MESSAGE("Unable to determine install path: "+error.summary());
      return ProgramStatus::exitFailure();
   }

   // special program offline option (based on file existence at 
   // startup for easy bash script enable/disable of offline state)
   serverOffline_ = FilePath("/etc/rstudio/offline").exists();
   
   // program - name and execution
   options_description server("server");<commit_msg>check for empty string before resolving server options paths<commit_after>/*
 * ServerOptions.cpp
 *
 * Copyright (C) 2009-11 by RStudio, Inc.
 *
 * This program is licensed to you under the terms of version 3 of the
 * GNU Affero General Public License. This program is distributed WITHOUT
 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
 *
 */

#include <server/ServerOptions.hpp>

#include <core/ProgramStatus.hpp>
#include <core/ProgramOptions.hpp>
#include <core/FilePath.hpp>

#include <core/system/System.hpp>

#include <server/util/system/System.hpp>
#include <server/util/system/User.hpp>

using namespace core ;

namespace server {

namespace {

const char * const kDefaultProgramUser = "rstudio-server";

void resolvePath(const FilePath& installPath, std::string* pPath)
{
   if (!pPath->empty())
      *pPath = installPath.complete(*pPath).absolutePath();
}


} // anonymous namespace

Options& options()
{
   static Options instance ;
   return instance ;
}

ProgramStatus Options::read(int argc, char * const argv[])
{
   using namespace boost::program_options ;

   // compute install path
   FilePath installPath;
   Error error = core::system::installPath("..", argc, argv, &installPath);
   if (error)
   {
      LOG_ERROR_MESSAGE("Unable to determine install path: "+error.summary());
      return ProgramStatus::exitFailure();
   }

   // special program offline option (based on file existence at 
   // startup for easy bash script enable/disable of offline state)
   serverOffline_ = FilePath("/etc/rstudio/offline").exists();
   
   // program - name and execution
   options_description server("server");
{'fraction_non_alphanumeric': 0.11322360953461975, 'fraction_numerical': 0.00510783200908059, 'mean_word_length': 4.079250720461095, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4604550', 'n_tokens_mistral': 1029, 'n_tokens_neox': 989, 'n_words': 319}