APPLINK-6688: SDL related resources location impl
authorDmitriy Klimenko <DKlimenko@luxoft.com>
Tue, 8 Apr 2014 09:03:48 +0000 (02:03 -0700)
committerJustin Dickow <jjdickow@gmail.com>
Wed, 9 Jul 2014 18:08:45 +0000 (14:08 -0400)
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Conflicts:
src/components/config_profile/src/profile.cc
src/components/policy

15 files changed:
src/appMain/main.cc
src/appMain/smartDeviceLink.ini
src/components/application_manager/src/application_manager_impl.cc
src/components/application_manager/src/message_helper.cc
src/components/application_manager/src/resume_ctrl.cpp
src/components/config_profile/CMakeLists.txt
src/components/config_profile/include/config_profile/profile.h
src/components/config_profile/src/profile.cc
src/components/media_manager/src/media_manager_impl.cc
src/components/policy
src/components/resumption/CMakeLists.txt
src/components/resumption/include/resumption/last_state.h
src/components/resumption/src/last_state.cc
src/components/utils/include/utils/file_system.h
src/components/utils/src/file_system.cc

index 0d87369..c98ab6f 100644 (file)
@@ -219,8 +219,11 @@ int32_t main(int32_t argc, char** argv) {
 
   // --------------------------------------------------------------------------
   // Components initialization
-
-  profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
+  if ((argc > 1)&&(0 != argv)) {
+      profile::Profile::instance()->config_file_name(argv[1]);
+  } else {
+      profile::Profile::instance()->config_file_name("smartDeviceLink.ini");
+  }
 
   main_namespace::LifeCycle::instance()->StartComponents();
 
index 2b44c39..169db32 100644 (file)
@@ -25,6 +25,9 @@ AudioStreamingPort = 5080
 ;     in Ubuntu : PTHREAD_STACK_MIN = 16384
 ;     in QNX : PTHREAD_STACK_MIN = 256
 ;The value of a variable ThreadStackSize used only if its realy needed, other way stack size will be PTHREAD_STACK_MIN
+; 
+AppConfigFolder =
+AppStorageFolder =
 ThreadStackSize = 16384
 MixingAudioSupported = true
 HMICapabilities = hmi_capabilities.json
@@ -41,6 +44,7 @@ SupportedDiagModes = 0x01, 0x02, 0x03, 0x05, 0x06, 0x07, 0x09, 0x0A, 0x18, 0x19,
 SystemFilesPath = /tmp/fs/mp/images/ivsu_cache
 UseLastState = true
 
+
 [MEDIA MANAGER]
 EnableRedecoding = false
 ;VideoStreamConsumer = socket
@@ -75,6 +79,7 @@ HelpCommand = Help
 
 
 [AppInfo]
+; The path for applcations info storage.
 AppInfoStorage = app_info.dat
 
 [Policy]
index 2e33f2e..2bd7133 100644 (file)
@@ -1716,34 +1716,34 @@ void ApplicationManagerImpl::Unmute(VRTTSSessionChanging changing_state) {
 }
 
 mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
-  const std::vector<uint8_t>& binary_data, const std::string& file_path,
-  const uint32_t offset) {
-  LOG4CXX_INFO(
-    logger_,
-    "SaveBinaryWithOffset  binary_size = " << binary_data.size()
-    << " offset = " << offset);
+    const std::vector<uint8_t>& binary_data, const std::string& file_path,
+    const std::string& file_name, const uint32_t offset) {
+  LOG4CXX_INFO(logger_,
+               "SaveBinaryWithOffset  binary_size = " << binary_data.size()
+               << " offset = " << offset);
 
-  if (binary_data.size() > file_system::GetAvailableDiskSpace()) {
+  if (binary_data.size() > file_system::GetAvailableDiskSpace(file_path)) {
     LOG4CXX_ERROR(logger_, "Out of free disc space.");
     return mobile_apis::Result::OUT_OF_MEMORY;
   }
 
-  uint32_t file_size = file_system::FileSize(file_path);
+  const std::string full_file_path = file_path + "/" + file_name;
+  uint32_t file_size = file_system::FileSize(full_file_path);
   std::ofstream* file_stream;
   if (offset != 0) {
     if (file_size != offset) {
-      LOG4CXX_INFO(
-        logger_,
-        "ApplicationManagerImpl::SaveBinaryWithOffset offset does'n match existing filesize");
+      LOG4CXX_INFO(logger_,
+                   "ApplicationManagerImpl::SaveBinaryWithOffset offset"
+                   << " does'n match existing file size");
       return mobile_apis::Result::INVALID_DATA;
     }
-    file_stream = file_system::Open(file_path, std::ios_base::app);
+    file_stream = file_system::Open(full_file_path, std::ios_base::app);
   } else {
     LOG4CXX_INFO(
       logger_,
       "ApplicationManagerImpl::SaveBinaryWithOffset offset is 0, rewrite");
     // if offset == 0: rewrite file
-    file_stream = file_system::Open(file_path, std::ios_base::out);
+    file_stream = file_system::Open(full_file_path, std::ios_base::out);
   }
 
   if (!file_system::Write(file_stream, binary_data.data(),
@@ -1751,11 +1751,41 @@ mobile_apis::Result::eType ApplicationManagerImpl::SaveBinary(
     file_system::Close(file_stream);
     return mobile_apis::Result::GENERIC_ERROR;
   }
+
   file_system::Close(file_stream);
   LOG4CXX_INFO(logger_, "Successfully write data to file");
   return mobile_apis::Result::SUCCESS;
 }
 
+uint32_t ApplicationManagerImpl::GetAvailableSpaceForApp(
+    const std::string& app_name) {
+  const uint32_t app_quota = profile::Profile::instance()->app_dir_quota();
+  std::string app_storage_path =
+      profile::Profile::instance()->app_storage_folder();
+
+  app_storage_path += "/";
+  app_storage_path += app_name;
+
+  if (file_system::DirectoryExists(app_storage_path)) {
+    uint32_t size_of_directory = file_system::DirectorySize(app_storage_path);
+    if (app_quota < size_of_directory) {
+      return 0;
+    }
+
+    uint32_t current_app_quota = app_quota - size_of_directory;
+    uint32_t available_disk_space =
+        file_system::GetAvailableDiskSpace(app_storage_path);
+
+    if (current_app_quota > available_disk_space) {
+      return available_disk_space;
+    } else {
+      return current_app_quota;
+    }
+  } else {
+    return app_quota;
+  }
+}
+
 bool ApplicationManagerImpl::IsHMICooperating() const {
   return hmi_cooperating_;
 }
index 929c320..45750ee 100644 (file)
@@ -1919,16 +1919,17 @@ mobile_apis::Result::eType MessageHelper::VerifyImage(
     return mobile_apis::Result::INVALID_DATA;
   }
 
-  std::string relative_file_path;
-  if (file_name.size() > 0 && file_name[0] == '/') {
-    relative_file_path = file_name;
+  std::string full_file_path =
+      profile::Profile::instance()->app_storage_folder() + "/";
+
+  if (file_name.size() > 0 && file_name[0] == '/' ) {
+    full_file_path += file_name;
   } else {
-    relative_file_path = app->name();
-    relative_file_path += "/";
-    relative_file_path += file_name;
-  }
 
-  std::string full_file_path = file_system::FullPath(relative_file_path);
+    full_file_path += app->name();
+    full_file_path += "/";
+    full_file_path += file_name;
+  }
 
   if (!file_system::FileExists(full_file_path)) {
     return mobile_apis::Result::INVALID_DATA;
index 4f5c9e8..e1cefe0 100644 (file)
@@ -40,6 +40,7 @@ void ResumeCtrl::SaveAllApplications() {
 
 void ResumeCtrl::SaveApplication(ApplicationConstSharedPtr application) {
   LOG4CXX_INFO(logger_, "ResumeCtrl::SaveApplication");
+
   DCHECK(application.get());
 
   Json::Value* json_app = NULL;
index 70deb6b..72863ee 100644 (file)
@@ -1,8 +1,6 @@
 include_directories (
   ./include
   ../utils/include/
-  ../media_manager/include/
-  ../protocol_handler/include
 )
 
 set (SOURCES
index 642f50b..35cfdce 100644 (file)
@@ -57,6 +57,21 @@ class Profile : public utils::Singleton<Profile> {
     virtual ~Profile();
 
     /**
+      * @brief Returns true if HMI should be started, otherwise false
+      */
+    bool launch_hmi() const;
+
+    /**
+      * @brief Returns application configuration path
+      */
+    const std::string& app_config_folder() const;
+
+    /**
+      * @brief Returns application storage path
+      */
+    const std::string& app_storage_folder() const;
+
+    /**
      * @brief Returns the path to the config file
      */
     const std::string& config_file_name() const;
@@ -67,11 +82,6 @@ class Profile : public utils::Singleton<Profile> {
     void config_file_name(const std::string& fileName);
 
     /**
-      * @brief Returns true if HMI should be started, otherwise false
-      */
-    bool launch_hmi() const;
-
-    /**
      * @brief Returns server address
      */
     const std::string& server_address() const;
@@ -356,6 +366,8 @@ class Profile : public utils::Singleton<Profile> {
 
     // Members section
     bool                            launch_hmi_;
+    std::string                     app_config_folder_;
+    std::string                     app_storage_folder_;
     std::string                     config_file_name_;
     std::string                     server_address_;
     uint16_t                        server_port_;
index 634ef89..2334d19 100644 (file)
 #include "config_profile/ini_file.h"
 #include "utils/logger.h"
 #include "utils/threads/thread.h"
+#include "utils/file_system.h"
 
 namespace {
 const char* kMainSection = "MAIN";
-const char* kPolicySection = "Policy";
-
-const char* kDefaultPoliciesSnapshotFileName = "sdl_snapshot.json";
 // Heartbeat is disabled by default
 const uint32_t kDefaultHeartBeatTimeout = 0;
 }
@@ -53,8 +51,10 @@ log4cxx::LoggerPtr logger_ = log4cxx::LoggerPtr(
 
 namespace profile {
 Profile::Profile()
-    : config_file_name_("smartDeviceLink.ini"),
-      launch_hmi_(true),
+    : launch_hmi_(true),
+      app_config_folder_(""),
+      app_storage_folder_(""),
+      config_file_name_("smartDeviceLink.ini"),
       policies_file_name_("policy_table.json"),
       hmi_capabilities_file_name_("hmi_capabilities.json"),
       server_address_("127.0.0.1"),
@@ -80,11 +80,10 @@ Profile::Profile()
       list_files_in_none_(5),
       app_info_storage_("app_info.dat"),
       heart_beat_timeout_(kDefaultHeartBeatTimeout),
-      policy_shapshot_file_name_(kDefaultPoliciesSnapshotFileName),
       transport_manager_disconnect_timeout_(0),
       use_last_state_(false),
-      supported_diag_modes_() {
-  UpdateValues();
+      supported_diag_modes_(),
+      system_files_path_("/tmp/fs/mp/images/ivsu_cache"){
 }
 
 Profile::~Profile() {
@@ -106,6 +105,15 @@ bool Profile::launch_hmi() const {
   return launch_hmi_;
 }
 
+const std::string& Profile::app_config_folder() const {
+  return app_config_folder_;
+}
+
+const std::string& Profile::app_storage_folder() const {
+  return app_storage_folder_;
+}
+
+
 const std::string& Profile::policies_file_name() const {
   return policies_file_name_;
 }
@@ -242,10 +250,6 @@ const std::string& Profile::preloaded_pt_file() const {
   return preloaded_pt_file_;
 }
 
-const std::string&Profile::policies_snapshot_file_name() const{
-  return policy_shapshot_file_name_;
-}
-
 uint32_t Profile::transport_manager_disconnect_timeout() const {
   return transport_manager_disconnect_timeout_;
 }
@@ -254,6 +258,10 @@ bool Profile::use_last_state() const {
   return use_last_state_;
 }
 
+const std::string& Profile::system_files_path() const {
+  return system_files_path_;
+}
+
 const std::vector<uint32_t>& Profile::supported_diag_modes() const {
   return supported_diag_modes_;
 }
@@ -274,6 +282,39 @@ void Profile::UpdateValues() {
     LOG4CXX_INFO(logger_, "Set launch HMI to " << launch_hmi_);
   }
 
+  *value = '\0';
+  if ((0
+      != ini_read_value(config_file_name_.c_str(), "MAIN", "AppConfigFolder",
+                        value)) && ('\0' != *value)) {
+    app_config_folder_ = value;
+  } else {
+    // use current working directory
+    app_config_folder_ = file_system::CurrentWorkingDirectory();
+  }
+  LOG4CXX_INFO(logger_, "Set App config folder to " << app_config_folder_);
+
+  *value = '\0';
+  if ((0
+      != ini_read_value(config_file_name_.c_str(), "MAIN", "AppStorageFolder",
+                        value)) && ('\0' != *value)) {
+    app_storage_folder_ = value;
+  } else {
+    // use current working directory
+    app_storage_folder_ = file_system::CurrentWorkingDirectory();
+  }
+  LOG4CXX_INFO(logger_, "Set App storage folder to " << app_storage_folder_);
+
+  *value = '\0';
+  if ((0
+      != ini_read_value(config_file_name_.c_str(), "AppInfo", "AppInfoStorage",
+                        value)) && ('\0' != *value)) {
+    app_info_storage_ = app_storage_folder_ + "/" + value;
+    LOG4CXX_INFO(
+        logger_,
+        "Set Application information storage to " << app_info_storage_);
+  }
+
+  *value = '\0';
   if ((0
       != ini_read_value(config_file_name_.c_str(), "HMI", "ServerAddress",
                         value)) && ('\0' != *value)) {
@@ -283,33 +324,27 @@ void Profile::UpdateValues() {
 
   *value = '\0';
   if ((0 != ini_read_value(config_file_name_.c_str(),
-                           kPolicySection, "PoliciesTable", value))
+                           "Policy", "PoliciesTable", value))
       && ('\0' != *value)) {
-    policies_file_name_ = value;
+    policies_file_name_ = app_config_folder_ + value;
     LOG4CXX_INFO(logger_, "Set policy file to " << policies_file_name_);
   }
 
   *value = '\0';
   if ((0 != ini_read_value(config_file_name_.c_str(),
-                           kPolicySection, "PreloadedPT", value))
+                           "Policy", "PreloadedPT", value))
       && ('\0' != *value)) {
-    preloaded_pt_file_ = value;
+    preloaded_pt_file_ = app_config_folder_ + value;
     LOG4CXX_INFO(logger_, "Set preloaded policy file to "
                  << preloaded_pt_file_);
   }
 
-  (void) ReadStringValue(&policy_shapshot_file_name_,
-                         kDefaultPoliciesSnapshotFileName,
-                         kPolicySection, "PathToSnapshot");
-
-  *value = '\0';
-  if ((0 != ini_read_value(config_file_name_.c_str(),
-                           "MAIN", "HMICapabilities", value))
-      && ('\0' != *value)) {
-    hmi_capabilities_file_name_ = value;
-    LOG4CXX_INFO(
-        logger_,
-        "Set hmi capabilities file to " << hmi_capabilities_file_name_);
+  if ((0
+      != ini_read_value(config_file_name_.c_str(), "MAIN", "HMICapabilities",
+                        value)) && ('\0' != *value)) {
+    hmi_capabilities_file_name_ = app_config_folder_ + "/" +  value;
+    LOG4CXX_INFO(logger_,
+                 "Set hmi capabilities file to " << hmi_capabilities_file_name_);
   }
 
   *value = '\0';
@@ -398,7 +433,7 @@ void Profile::UpdateValues() {
   if ((0
       != ini_read_value(config_file_name_.c_str(), "MEDIA MANAGER",
                         "VideoStreamFile", value)) && ('\0' != *value)) {
-    video_stream_file_ = value;
+    video_stream_file_ = app_storage_folder_ + "/" + value;
     LOG4CXX_INFO(logger_, "Set video stream file to " << video_stream_file_);
   }
 
@@ -406,7 +441,7 @@ void Profile::UpdateValues() {
   if ((0 != ini_read_value(config_file_name_.c_str(),
                            "MEDIA MANAGER", "AudioStreamFile", value))
       && ('\0' != *value)) {
-    audio_stream_file_ = value;
+    audio_stream_file_ = app_storage_folder_ + "/" + value;
     LOG4CXX_INFO(logger_, "Set audio stream file to " << audio_stream_file_);
   }
 
@@ -602,16 +637,6 @@ void Profile::UpdateValues() {
         "Set system pending requests amount " << pending_requests_amount_);
   }
 
-  *value = '\0';
-  if ((0
-      != ini_read_value(config_file_name_.c_str(), "AppInfo", "AppInfoStorage",
-                        value)) && ('\0' != *value)) {
-    app_info_storage_ = value;
-    LOG4CXX_INFO(
-        logger_,
-        "Set Application information storage to " << app_info_storage_);
-  }
-
   supported_diag_modes_.clear();
   *value = '\0';
   if ((0
@@ -625,6 +650,14 @@ void Profile::UpdateValues() {
     }
   }
 
+  *value = '\0';
+  if ((0
+      != ini_read_value(config_file_name_.c_str(), "MAIN",
+                        "SystemFilesPath", value)) && ('\0' != *value)) {
+    system_files_path_ = value;
+    LOG4CXX_INFO(logger_, "Set system files path to " << system_files_path_);
+  }
+
   (void) ReadIntValue(&heart_beat_timeout_, kDefaultHeartBeatTimeout,
                       kMainSection, "HeartBeatTimeout");
 
index 94e042b..1ff903e 100644 (file)
@@ -157,11 +157,14 @@ void MediaManagerImpl::StartMicrophoneRecording(
   application_manager::ApplicationSharedPtr app =
     application_manager::ApplicationManagerImpl::instance()->
       application(application_key);
-  std::string relative_file_path =
-    file_system::CreateDirectory(app->name());
-  relative_file_path += "/";
-  relative_file_path += output_file;
-  from_mic_listener_ = new FromMicRecorderListener(relative_file_path);
+  std::string file_path = profile::Profile::instance()->app_storage_folder();
+  file_path += "/";
+  file_path += app->name();
+  file_system::CreateDirectory(file_path);
+
+  file_path += "/";
+  file_path += output_file;
+  from_mic_listener_ = new FromMicRecorderListener(file_path);
 #if defined(EXTENDED_MEDIA_MODE)
   if (from_mic_recorder_) {
     from_mic_recorder_->AddListener(from_mic_listener_);
@@ -172,19 +175,20 @@ void MediaManagerImpl::StartMicrophoneRecording(
     from_mic_recorder_->StartActivity(application_key);
   }
 #else
-  if (file_system::FileExists(relative_file_path)) {
+  if (file_system::FileExists(file_path)) {
     LOG4CXX_INFO(logger_, "File " << output_file << " exists, removing");
-    if (file_system::DeleteFile(relative_file_path)) {
+    if (file_system::DeleteFile(file_path)) {
       LOG4CXX_INFO(logger_, "File " << output_file << " removed");
     }
     else {
       LOG4CXX_WARN(logger_, "Could not remove file " << output_file);
     }
   }
-  const std::string predefined_rec_file = "audio.8bit.wav";
+  const std::string predefined_rec_file =
+      profile::Profile::instance()->app_storage_folder() + "/audio.8bit.wav";
   std::vector<uint8_t> buf;
   if (file_system::ReadBinaryFile(predefined_rec_file, buf)) {
-    if (file_system::Write(relative_file_path, buf)) {
+    if (file_system::Write(file_path, buf)) {
       LOG4CXX_INFO(logger_,
         "File " << predefined_rec_file << " copied to " << output_file);
     }
@@ -230,8 +234,8 @@ void MediaManagerImpl::StartVideoStreaming(int32_t application_key) {
         snprintf(url, sizeof(url) / sizeof(url[0]), "%s",
                  profile::Profile::instance()->named_video_pipe_path().c_str());
       } else {
-        DCHECK(snprintf(url, sizeof(url) / sizeof(url[0]), "%s", file_system::FullPath(
-            profile::Profile::instance()->video_stream_file()).c_str()));
+        DCHECK(snprintf(url, sizeof(url) / sizeof(url[0]), "%s",
+            profile::Profile::instance()->video_stream_file().c_str()));
       }
       application_manager::MessageHelper::SendNaviStartStream(url,
                                                               application_key);
@@ -267,8 +271,7 @@ void MediaManagerImpl::StartAudioStreaming(int32_t application_key) {
                  profile::Profile::instance()->named_audio_pipe_path().c_str());
       } else {
         DCHECK(snprintf(url, sizeof(url) / sizeof(url[0]), "%s",
-               file_system::FullPath(profile::Profile::instance()->
-                                     audio_stream_file()).c_str()));
+             profile::Profile::instance()->audio_stream_file().c_str()));
       }
 
       application_manager::MessageHelper::SendAudioStartStream(url,
index dcb8e5a..c2ad2f6 160000 (submodule)
@@ -1 +1 @@
-Subproject commit dcb8e5a81ee4dbd771f5c3142a5c60132e12f608
+Subproject commit c2ad2f65576e200d8977acbcc046606c0dcb1360
index 5352d87..93752a9 100644 (file)
@@ -1,6 +1,7 @@
 include_directories (
   ./include
   ../utils/include/
+  ../config_profile/include/
   ${CMAKE_SOURCE_DIR}/src/thirdPartyLibs/jsoncpp/include
 )
 
index 4380542..f39108d 100644 (file)
@@ -50,10 +50,6 @@ class LastState : public utils::Singleton<LastState> {
 
  private:
 /**
- * @brief File to save Dictionary
- */
-  static const std::string filename;
-/**
  * @brief Saving dictionary to filesystem
  */
   void SaveToFileSystem();
index ebf4ce8..f694a99 100644 (file)
  */
 
 #include "resumption/last_state.h"
+#include "config_profile/profile.h"
 #include "utils/file_system.h"
 
 namespace resumption {
 
-const std::string LastState::filename = "LastState.dat";
-
 void LastState::SaveToFileSystem() {
+  const std::string file =
+      profile::Profile::instance()->app_info_storage();
   const std::string& str = dictionary.toStyledString();
   const std::vector<uint8_t> char_vector_pdata(
     str.begin(), str.end());
-  DCHECK(file_system::Write(filename, char_vector_pdata));
+  DCHECK(file_system::Write(file, char_vector_pdata));
 }
 
 void LastState::LoadFromFileSystem() {
+  const std::string file =
+      profile::Profile::instance()->app_info_storage();
   std::string buffer;
-  bool result = file_system::ReadFile(filename,buffer);
+  bool result = file_system::ReadFile(filebuffer);
   if (result) {
     Json::Reader m_reader;
     DCHECK(m_reader.parse(buffer, dictionary));
index e699ecd..fb55b97 100644 (file)
@@ -46,9 +46,10 @@ namespace file_system {
 /**
  * @brief Get available disc space.
  *
+ * @param path to directory
  * @return free disc space.
  */
-uint64_t GetAvailableDiskSpace();
+uint64_t GetAvailableDiskSpace(const std::string& path);
 
 /*
  * @brief Get size of current directory
@@ -65,14 +66,6 @@ uint32_t DirectorySize(const std::string& path);
  */
 uint32_t FileSize(const std::string& path);
 
-
-/**
- * @brief Get available app space
- * @param name of app
- * @return free app space.
- */
-uint32_t GetAvailableSpaceForApp(const std::string& name);
-
 /**
  * @brief Creates directory
  * @param name path to directory
@@ -140,12 +133,12 @@ bool Write(std::ofstream* const file_stream,
 void Close(std::ofstream* file_stream);
 
 /**
-  * @brief Returns full file path
+  * @brief Returns current working directory path
   * If filename begins with "/", return unchanged filename
   * @param name file name
   * @return returns full file path.
   */
-std::string FullPath(const std::string& name);
+std::string CurrentWorkingDirectory();
 
 /**
   * @brief Removes file
index 63efbea..b0cc8ba 100644 (file)
 #include <fstream>
 #include <cstddef>
 #include <algorithm>
-#include "config_profile/profile.h"
-
-uint64_t file_system::GetAvailableDiskSpace() {
-  char currentAppPath[FILENAME_MAX];
-  memset(reinterpret_cast<void*>(currentAppPath), 0, FILENAME_MAX);
-  getcwd(currentAppPath, FILENAME_MAX - 1);
 
+uint64_t file_system::GetAvailableDiskSpace(const std::string& path) {
   struct statvfs fsInfo;
   memset(reinterpret_cast<void*>(&fsInfo), 0, sizeof(fsInfo));
-  if( statvfs(currentAppPath, &fsInfo) == 0) {
+  if (statvfs(path.c_str(), &fsInfo) == 0) {
     return fsInfo.f_bsize * fsInfo.f_bfree;
   } else {
     return 0;
@@ -110,26 +105,6 @@ uint32_t file_system::DirectorySize(const std::string& path) {
   return size;
 }
 
-uint32_t file_system::GetAvailableSpaceForApp(const std::string& app_name) {
-  const uint32_t app_quota = profile::Profile::instance()->app_dir_quota();
-  if (DirectoryExists(app_name)) {
-    std::string full_path = FullPath(app_name);
-    uint32_t size_of_directory = DirectorySize(full_path);
-    if (app_quota < size_of_directory) {
-      return 0;
-    }
-    uint32_t current_app_quota = app_quota - size_of_directory;
-    uint32_t available_disk_space = GetAvailableDiskSpace();
-    if (current_app_quota > available_disk_space) {
-      return available_disk_space;
-    } else {
-      return current_app_quota;
-    }
-  } else {
-    return app_quota;
-  }
-}
-
 std::string file_system::CreateDirectory(const std::string& name) {
   if (!DirectoryExists(name)) {
     mkdir(name.c_str(), S_IRWXU);
@@ -184,8 +159,6 @@ bool file_system::Write(
   return false;
 }
 
-
-
 std::ofstream* file_system::Open(const std::string& file_name,
                                  std::ios_base::openmode mode) {
 
@@ -219,13 +192,7 @@ void file_system::Close(std::ofstream* file_stream) {
   }
 }
 
-std::string file_system::FullPath(const std::string& file) {
-  // FILENAME_MAX defined stdio_lim.h was replaced with less value
-  // since it seems, that is caused overflow in some cases
-  if (file.size() > 0 && file[0] == '/') {
-    return file;
-  }
-
+std::string file_system::CurrentWorkingDirectory() {
   size_t filename_max_lenght = 1024;
   char currentAppPath[filename_max_lenght];
   memset(currentAppPath, 0, filename_max_lenght);
@@ -233,7 +200,7 @@ std::string file_system::FullPath(const std::string& file) {
 
   char path[filename_max_lenght];
   memset(path, 0, filename_max_lenght);
-  snprintf(path, filename_max_lenght - 1, "%s/%s", currentAppPath, file.c_str());
+  snprintf(path, filename_max_lenght - 1, "%s", currentAppPath);
   return std::string(path);
 }