Ejemplo n.º 1
0
bool preparedir(const char *destination)
{
    string dir;
    copystring(dir, parentdir(destination));
    vector<char *> dirs;
    while(!fileexists(dir, "r"))
    {
        dirs.add(newstring(dir));
        copystring(dir, parentdir(dir));
    }
    
    loopvrev(dirs) if(!createdir(dirs[i])) return false;
    return true;
}
Ejemplo n.º 2
0
void CompressThread::run()
{
	if (!_done)
		return;
	_done = false;
	QDir parentdir(_findRootDir);
	QString dirName = parentdir.dirName();
	if (parentdir.isRoot())
	{
		_done = true;
		return;
	}
	parentdir.cdUp();
	QString parentDir = parentdir.absolutePath();
	QDir targetDir(_targetRootDir);
	if (!targetDir.exists())
		targetDir.mkpath(_targetRootDir);
	QString targetFileName = _targetRootDir;
	if (!targetFileName.endsWith("/"))
		targetFileName.append("/");
	targetFileName.append(dirName);
	targetFileName.append(".zip");
	compressDir(parentDir, dirName, targetFileName, _convertType == ToUtf8);
	_done = true;
	emit signalTaskDone();
}
Ejemplo n.º 3
0
bool fileexists(const char *path, const char *mode)
{
    bool exists = true;
    if(mode[0]=='w' || mode[0]=='a') path = parentdir(path);
#ifdef WIN32
    if(GetFileAttributes(path) == INVALID_FILE_ATTRIBUTES) exists = false;
#else
    if(access(path, R_OK | (mode[0]=='w' || mode[0]=='a' ? W_OK : 0)) == -1) exists = false;
#endif
    return exists;
}
Ejemplo n.º 4
0
Archivo: dl.hpp Proyecto: PGGB/Higan
inline bool library::open(const string& name, const string& path) {
  if(handle) close();
  handle = (uintptr_t)dlopen(string(path, !path.empty() && !path.endsWith("/") ? "/" : "", "lib", name, ".dylib"), RTLD_LAZY);
  if(!handle) {
    Dl_info info;
    dladdr((void*)&junk_function, &info);
    handle = (uintptr_t)dlopen(string(parentdir(info.dli_fname), "lib", name, ".dylib"), RTLD_LAZY);
  }
  if(!handle) handle = (uintptr_t)dlopen(string("/usr/local/lib/lib", name, ".dylib"), RTLD_LAZY);
  return handle;
}
Ejemplo n.º 5
0
const std::string  Uri::getParentDir() const
{
	const std::string& p = getPath();
	std::string parentdir(p);

	if ( !parentdir.empty() && parentdir[parentdir.size()-1] == '/' )
	{
		parentdir = parentdir.substr(0,parentdir.size()-1);
	}

	size_t pos = parentdir.find_last_of("/");
	if ( pos != std::string::npos && pos != 0)
	{
		parentdir = parentdir.substr(0,pos);
	}
	return parentdir;
}