コード例 #1
0
ファイル: al_XML.cpp プロジェクト: Devil-hmr/AlloSystem
	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);
	}
コード例 #2
0
	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));
		}
	}
コード例 #3
0
ファイル: al_FileAPR.cpp プロジェクト: gitelope/AlloSystem
	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;
	}
コード例 #4
0
	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();
	}
コード例 #5
0
ファイル: al_FileAPR.cpp プロジェクト: gitelope/AlloSystem
	virtual ~Path() {
		if (dir != NULL) check_apr(apr_dir_close(dir));
	}
コード例 #6
0
ファイル: al_FileAPR.cpp プロジェクト: gitelope/AlloSystem
	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;
		}
	}
コード例 #7
0
ファイル: al_FileAPR.cpp プロジェクト: gitelope/AlloSystem
	bool getInfo(const char * path, apr_int32_t wanted) const {
		return (APR_SUCCESS == check_apr(apr_stat(&finfo, path, wanted, mPool)));
	}
コード例 #8
0
	bool remove(const std::string& path){
		return APR_SUCCESS == check_apr(apr_dir_remove(path.c_str(), mPool));
	}
コード例 #9
0
	bool rewind(){
		return APR_SUCCESS == check_apr(apr_dir_rewind(dir));
	}
コード例 #10
0
	bool close(){
		if(dir != NULL){
			return APR_SUCCESS == check_apr(apr_dir_close(dir));
		}
		return false;
	}
コード例 #11
0
	bool open(const std::string& dirName){
		return APR_SUCCESS ==
			check_apr(apr_dir_open(&dir, dirName.c_str(), mPool));
	}