CUpdateSettings:: allow choose tmp(ramfs,TMPFS_MAGIC) as update dir

Origin commit data
------------------
Branch: ni/coolstream
Commit: 6f07cbe3dd
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2013-10-08 (Tue, 08 Oct 2013)

Origin message was:
------------------
CUpdateSettings:: allow choose tmp(ramfs,TMPFS_MAGIC) as update dir

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
Jacek Jendrzej
2013-10-08 10:10:10 +02:00
parent af33300905
commit 07ccabf7c3
5 changed files with 16 additions and 12 deletions

View File

@@ -1418,23 +1418,23 @@ void CFileBrowser::paintHead()
free(l_name);
}
bool chooserDir(char *setting_dir, bool test_dir, const char *action_str, size_t str_leng)
bool chooserDir(char *setting_dir, bool test_dir, const char *action_str, size_t str_leng, bool allow_tmp)
{
std::string tmp_setting_dir = setting_dir;
if(chooserDir(tmp_setting_dir, test_dir, action_str)){
if(chooserDir(tmp_setting_dir, test_dir, action_str,allow_tmp)){
strncpy(setting_dir,tmp_setting_dir.c_str(), str_leng);
return true;
}
return false;
}
bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str)
bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str, bool allow_tmp)
{
const char *wrong_str = "Wrong/unsupported";
CFileBrowser b;
b.Dir_Mode=true;
if (b.exec(setting_dir.c_str())) {
const char * newdir = b.getSelectedFile()->Name.c_str();
if(test_dir && check_dir(newdir)){
if(test_dir && check_dir(newdir,allow_tmp)){
printf("%s %s dir %s\n",wrong_str ,action_str, newdir);
return false;
}else {

View File

@@ -56,8 +56,8 @@
#define ENABLE_INTERNETRADIO
#define VLC_URI "vlc://"
bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str);
bool chooserDir(char *setting_dir, bool test_dir, const char *action_str, size_t str_leng);
bool chooserDir(std::string &setting_dir, bool test_dir, const char *action_str, bool allow_tmp = false);
bool chooserDir(char *setting_dir, bool test_dir, const char *action_str, size_t str_leng, bool allow_tmp = false);
/**
* Converts input of numeric keys to SMS style char input.

View File

@@ -93,7 +93,7 @@ int CUpdateSettings::exec(CMenuTarget* parent, const std::string &actionKey)
if(actionKey == "update_dir") {
const char *action_str = "update";
if(chooserDir(g_settings.update_dir, true, action_str, sizeof(g_settings.update_dir)-1))
if(chooserDir(g_settings.update_dir, true, action_str, sizeof(g_settings.update_dir)-1,true))
printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir);
return res;

View File

@@ -206,7 +206,7 @@ int safe_mkdir(char * path)
}
/* function used to check is this dir writable, i.e. not flash, for record etc */
int check_dir(const char * dir)
int check_dir(const char * dir, bool allow_tmp)
{
/* default to return, if statfs fail */
int ret = -1;
@@ -223,12 +223,16 @@ int check_dir(const char * dir)
case 0x58465342L: /*xfs*/
case 0x4d44L: /*msdos*/
case 0x0187: /* AUTOFS_SUPER_MAGIC */
case 0x858458f6L: /*ramfs*/
#if 0
case 0x72b6L: /*jffs2*/
#endif
ret = 0;
break; //ok
ret = 0;//ok
break;
case 0x858458f6L: /*ramfs*/
case 0x1021994: /*TMPFS_MAGIC*/
if(allow_tmp)
ret = 0;//ok
break;
default:
fprintf(stderr, "%s Unknown filesystem type: 0x%x\n", dir, (int)s.f_type);
break; // error

View File

@@ -32,7 +32,7 @@ int safe_mkdir(char * path);
off_t file_size(const char *filename);
bool file_exists(const char *filename);
void wakeup_hdd(const char *hdd_dir);
int check_dir(const char * dir);
int check_dir(const char * dir, bool allow_tmp = false);
bool get_fs_usage(const char * dir, long &total, long &used, long *bsize=NULL);
bool get_mem_usage(unsigned long &total, unsigned long &free);