Esempio n. 1
0
	Impl(const std::string src) : ImplAPR(), parser(NULL), doc(NULL) {
		parser = apr_xml_parser_create(mPool);
		check_apr(apr_xml_parser_feed(parser, src.c_str(), src.size()));
		check_apr(apr_xml_parser_done(parser, &doc));
		
		apr_xml_elem *root;
		root = doc->root;
		printf("root-element; name = %s, text = %s\n", root->name, root->first_cdata.first->text);
		//traverse_xml_tree(root, mp);
	}
	bool make(const std::string& path, int perms, bool recursive){

	 	apr_fileperms_t apr_perms = APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE;

		if(recursive){
			return APR_SUCCESS == check_apr(apr_dir_make_recursive(path.c_str(), apr_perms, mPool));
		}
		else {
			return APR_SUCCESS == check_apr(apr_dir_make(path.c_str(), apr_perms, mPool));
		}
	}
Esempio n. 3
0
	bool find(const std::string& name, FilePath& result, bool recursive=true) {
		bool found = false;
		if (dir && APR_SUCCESS == check_apr(apr_dir_open(&dir, dirname.c_str(), mPool))) {
			// iterate over directory:
			while ((!found) && APR_SUCCESS == (apr_dir_read(&dirent, APR_FINFO_TYPE|APR_FINFO_NAME, dir))) {
				//printf("test %s %s\n", dirname.c_str(), dirent.name);
				if (dirent.filetype == APR_REG && dirent.name && std::string(dirent.name) == name) {
					result.file(dirent.name);
					result.path(dirname);
					found = true;
					break;
				} else if (recursive && dirent.filetype == APR_DIR && dirent.name && dirent.name[0] != '.') {
					Path path(dirname + dirent.name + AL_FILE_DELIMITER);
					found = path.find(name, result, true);
				}
			}
		} else {
			printf("couldn't open directory %s\n", dirname.c_str());
		}
		return found;
	}
	int glob(const std::string& regex, FileList& result, bool recursive=true) {
		std::regex e(regex);
		if (dir && APR_SUCCESS == check_apr(apr_dir_open(&dir, dirname.c_str(), mPool))) {
			// iterate over directory:
			while (APR_SUCCESS == (apr_dir_read(&dirent, APR_FINFO_TYPE|APR_FINFO_NAME, dir))) {
				//printf("test %s %s\n", dirname.c_str(), dirent.name);
				if (dirent.filetype == APR_REG && dirent.name && std::regex_match(dirname+dirent.name,e) ) {
					FilePath res;
					res.file(dirent.name);
					res.path(dirname);
					result.add(res);
				} else if (recursive && dirent.filetype == APR_DIR && dirent.name && dirent.name[0] != '.') {
					Path path(dirname + dirent.name + AL_FILE_DELIMITER);
					path.glob(regex, result, true);
				}
			}
		} else {
			AL_WARN("couldn't open directory %s", dirname.c_str());
		}
		return result.count();
	}
Esempio n. 5
0
	virtual ~Path() {
		if (dir != NULL) check_apr(apr_dir_close(dir));
	}
Esempio n. 6
0
	Path(const std::string& dirname) : ImplAPR(), dir(NULL), dirname(dirname) {
		if (APR_SUCCESS != check_apr(apr_dir_open(&dir, dirname.c_str(), mPool))) {
			//printf("dir %p\n", dir);
			dir=NULL;
		}
	}
Esempio n. 7
0
	bool getInfo(const char * path, apr_int32_t wanted) const {
		return (APR_SUCCESS == check_apr(apr_stat(&finfo, path, wanted, mPool)));
	}
	bool remove(const std::string& path){
		return APR_SUCCESS == check_apr(apr_dir_remove(path.c_str(), mPool));
	}
	bool rewind(){
		return APR_SUCCESS == check_apr(apr_dir_rewind(dir));
	}
	bool close(){
		if(dir != NULL){
			return APR_SUCCESS == check_apr(apr_dir_close(dir));
		}
		return false;
	}
	bool open(const std::string& dirName){
		return APR_SUCCESS ==
			check_apr(apr_dir_open(&dir, dirName.c_str(), mPool));
	}