Пример #1
0
/*初始化操作*/
void init(){
    int fd, n, len;
    char c, buf[80];

	//打开查找路径文件ysh.conf
    if((fd = open("ysh.conf", O_RDONLY, 660)) == -1){
        perror("init environment failed\n");
        exit(1);
    }
    
	//初始化history链表
    history.end = -1;
    history.start = 0;
    
    len = 0;
	//将路径文件内容依次读入到buf[]中
    while(read(fd, &c, 1) != 0){ 
        buf[len++] = c;
    }
    buf[len] = '\0';

    //将环境路径存入envPath[]
    getEnvPath(len, buf); 
    
    //注册信号
    struct sigaction action;
    action.sa_sigaction = rmJob;
    sigfillset(&action.sa_mask);
    action.sa_flags = SA_SIGINFO;
    sigaction(SIGCHLD, &action, NULL);
    signal(SIGTSTP, ctrl_Z);
    signal(SIGINT, ctrl_C);
}
Пример #2
0
void prependEnvPath(string const & name, string const & prefix)
{
	vector<string> env_var = getEnvPath(name);

	typedef boost::char_separator<char> Separator;
	typedef boost::tokenizer<Separator> Tokenizer;

	Separator const separator(string(1, os::path_separator()).c_str());

	// Prepend each new element to the list, removing identical elements
	// that occur later in the list.
	Tokenizer const tokens(prefix, separator);
	vector<string> reversed_tokens(tokens.begin(), tokens.end());

	typedef vector<string>::const_reverse_iterator token_iterator;
	token_iterator it = reversed_tokens.rbegin();
	token_iterator const end = reversed_tokens.rend();
	for (; it != end; ++it) {
		vector<string>::iterator remove_it =
			remove(env_var.begin(), env_var.end(), *it);
		env_var.erase(remove_it, env_var.end());
		env_var.insert(env_var.begin(), *it);
	}

	setEnvPath(name, env_var);
}
Пример #3
0
void ddMainWindow::getMemoryFolderNames()
{
    // даем значения папкам мобильного телефона
   dataFolder = getEnvPath(eDATA);

   if (dataFolder.isEmpty()) // на случай если не удалось получить название директории из телефона
       dataFolder = "/data";

   sdcardFolder = getEnvPath(eSDCARD);

   if (sdcardFolder.isEmpty())
        sdcardFolder = "/sdcard";

   extsdcardFolder = getEnvPath(eSDCARD_EXT);

   if (extsdcardFolder.isEmpty())
        sdcardFolder = "/sdcard2";

}
Пример #4
0
//getFilePath will look for a valid data file in several places
void getFilePath(char path[], struct PState * pstate)
{
	if (!getArgPath(path, pstate)) {
		if ( ! getEnvPath(path)) {
			if ( ! getLocalPath(path)) {
				strcat(path, ITEMFILENAME);
			}
		}
	}
	if (! testPath(path)) {
		printf("Could not find a valid data file at %s\n", path);
		exit(EXIT_FAILURE);
	}
}
Пример #5
0
//--------------------------------------------------------------------
void variablesHandler::fillFile ()
{
    fileName_ = getEnvPath("TOGNAZZIOUTPUTDIR").toStdString() + "/" + fileName_;

    theFile_ = TFile::Open(fileName_.c_str(), "RECREATE");
 }