Ejemplo n.º 1
0
void SeafileTrayIcon::shellExtFix()
{
#if defined(Q_OS_WIN32)
    QString application_dir = QCoreApplication::applicationDirPath();
    QString shellext_fix_path = pathJoin(application_dir, kShellExtFixExecutableName);
    shellext_fix_path = QString("\"%1\"").arg(shellext_fix_path);

    QString log_dir = QDir(seafApplet->configurator()->ccnetDir()).absoluteFilePath("logs");
    QString log_path = pathJoin(log_dir, kShellFixLogName);

    qWarning("will exec shellext fix command is: %s, the log path is: %s",
        toCStr(shellext_fix_path),
        toCStr(log_path));

    DWORD res = utils::win::runShellAsAdministrator(toCStr(shellext_fix_path), toCStr(log_path), SW_HIDE);
    if (res == 0) {
        seafApplet->warningBox(tr("Successfully fixed sync status icons for Explorer"));

    } else {
        seafApplet->warningBox(tr("Faild to fix sync status icons for Explorer"));
        qWarning("faild to fix sync status icons for explorer");
    }

#endif
}
Ejemplo n.º 2
0
TestMain::TestMain() :
    log(new Logger),
    mConfig()
{
    fileName = getSelfName();
    log->setLogFile(pathJoin(settings.localDataDir, "manaplustest.log"));
}
Ejemplo n.º 3
0
void TestPathJoin(L_REGPARAMS  *rp,
                  const char   *first,
                  const char   *second,
                  const char   *result)
{
char  *newfirst = NULL;
char  *newsecond = NULL;
char  *newpath = NULL;

    char *path = pathJoin(first, second);
    regTestCompareStrings(rp, (l_uint8 *)result, strlen(result),
                          (l_uint8 *)path, strlen(path));
    if (first && first[0] == '\0')
        newfirst = stringNew("\"\"");
    else if (first)
        newfirst = stringNew(first);
    if (second && second[0] == '\0')
        newsecond = stringNew("\"\"");
    else if (second)
        newsecond = stringNew(second);
    if (path && path[0] == '\0')
        newpath = stringNew("\"\"");
    else if (path)
        newpath = stringNew(path);
    if (rp->display)
        fprintf(stderr, "join: %s + %s --> %s\n", newfirst, newsecond, newpath);
    lept_free(path);
    lept_free(newfirst);
    lept_free(newsecond);
    lept_free(newpath);
    return;
}
Ejemplo n.º 4
0
QString pathJoin(const QString& a,
                 const QString& b,
                 const QString& c)
{
    QStringList list;
    list << b << c;
    return pathJoin(a, list);
}
Ejemplo n.º 5
0
AnimatedSprite *StatusEffect::getIcon() const
{
    if (mIcon.empty())
    {
        return nullptr;
    }
    return AnimatedSprite::load(
        pathJoin(paths.getStringValue("sprites"), mIcon),
        0);
}
Ejemplo n.º 6
0
int TestMain::readValue(const int ver, int def)
{
    std::string tmp;
    int var;
    std::ifstream file;
    file.open(pathJoin(settings.localDataDir, "test.log").c_str(),
        std::ios::in);
    if (!getline(file, tmp))
    {
        file.close();
        return def;
    }
    var = atoi(tmp.c_str());
    if (ver != var || !getline(file, tmp))
    {
        file.close();
        return def;
    }
    def = atoi(tmp.c_str());
    file.close();
    return def;
}
Ejemplo n.º 7
0
static status_t lklfs_lookup(fs_volume* volume, fs_vnode* dir,
	const char* name,  ino_t* _id)
{
	ino_t ino;
	char * filePath = pathJoin(dir->private_node, name);
	if (filePath == NULL)
		return B_NO_MEMORY;

	ino = lklfs_get_ino(volume->private_volume, filePath);
	if (ino < 0)
		return lh_to_haiku_error(-ino);

	*_id = ino;

	// TODO: FIXME: get_vnode + the get_vnode hook do not permit
	// us to put the file path into the fs_vnode->private_node field.
	// get_vnode_set_private_node is a new function exported that
	// permits setting the private_node field in a safe manner.

	// return get_vnode(volume, ino, &private_node);
	return get_vnode_set_private_node(volume, ino, filePath);
}
Ejemplo n.º 8
0
// returns:
// - S_OK if there are files
// - S_FALSE if there are none
// - an error code otherwise
HRESULT startFindFile(WCHAR *path, struct findFile **out)
{
	struct findFile *ff;
	WCHAR *finddir;
	HRESULT hr;

	// initialize output parameters
	*out = NULL;

	ff = (struct findFile *) malloc(sizeof (struct findFile));
	if (ff == NULL)
		return E_OUTOFMEMORY;
	ZeroMemory(ff, sizeof (struct findFile));

	hr = pathJoin(path, L"*", &finddir);
	if (hr != S_OK) {
		free(ff);
		return hr;
	}

	// get the first file now
	// findFileNext() will see that ff->first is TRUE and return immediately; we can get that first file's info then
	ff->first = TRUE;
	ff->dir = FindFirstFileW(finddir, &(ff->entry));
	if (ff->dir == INVALID_HANDLE_VALUE)
		if (ffReallyNoMoreFiles(ff, ERROR_FILE_NOT_FOUND)) {
			// no files
			pathFree(finddir);
			free(ff);
			return S_FALSE;
		}

	pathFree(finddir);
	*out = ff;
	return S_OK;
}
Ejemplo n.º 9
0
QString pathJoin(const QString& a,
                 const QString& b)
{
    QStringList list(b);
    return pathJoin(a, list);
}
Ejemplo n.º 10
0
l_int32 main(int    argc,
             char **argv)
{
l_int32       exists;
L_REGPARAMS  *rp;

    if (regTestSetup(argc, argv, &rp))
        return 1;

    fprintf(stderr, " ===================================================\n");
    fprintf(stderr, " =================== Test pathJoin() ===============\n");
    fprintf(stderr, " ===================================================\n");
    TestPathJoin(rp, "/a/b//c///d//", "//e//f//g//", "/a/b/c/d/e/f/g");  /* 0 */
    TestPathJoin(rp, "/tmp/", "junk//", "/tmp/junk");  /* 1 */
    TestPathJoin(rp, "//tmp/", "junk//", "/tmp/junk");  /* 2 */
    TestPathJoin(rp, "tmp/", "//junk//", "tmp/junk");  /* 3 */
    TestPathJoin(rp, "tmp/", "junk/////", "tmp/junk");  /* 4 */
    TestPathJoin(rp, "/tmp/", "///", "/tmp");  /* 5 */
    TestPathJoin(rp, "////", NULL, "/");  /* 6 */
    TestPathJoin(rp, "//", "/junk//", "/junk");  /* 7 */
    TestPathJoin(rp, NULL, "/junk//", "/junk");  /* 8 */
    TestPathJoin(rp, NULL, "//junk//", "/junk");  /* 9 */
    TestPathJoin(rp, NULL, "junk//", "junk");  /* 10 */
    TestPathJoin(rp, NULL, "//", "/");  /* 11 */
    TestPathJoin(rp, NULL, NULL, "");  /* 12 */
    TestPathJoin(rp, "", "", "");  /* 13 */
    TestPathJoin(rp, "/", "", "/");  /* 14 */
    TestPathJoin(rp, "", "//", "/");  /* 15 */
    TestPathJoin(rp, "", "a", "a");  /* 16 */

    fprintf(stderr, "The next 3 joins properly give error messages:\n");
    fprintf(stderr, "join: .. + a --> NULL\n");
    pathJoin("..", "a");  /* returns NULL */
    fprintf(stderr, "join: %s + .. --> NULL\n", "/tmp");
    pathJoin("/tmp", "..");  /* returns NULL */
    fprintf(stderr, "join: ./ + .. --> NULL\n");
    pathJoin("./", "..");  /* returns NULL */

    fprintf(stderr, "\n ===================================================\n");
    fprintf(stderr, " ======= Test lept_rmdir() and lept_mkdir()) =======\n");
    fprintf(stderr, " ===================================================\n");
    lept_rmdir("junkfiles");
    lept_direxists("/tmp/junkfiles", &exists);
    if (rp->display) fprintf(stderr, "directory removed?: %d\n", !exists);
    regTestCompareValues(rp, 0, exists, 0.0);  /* 17 */

    lept_mkdir("junkfiles");
    lept_direxists("/tmp/junkfiles", &exists);
    if (rp->display) fprintf(stderr, "directory made?: %d\n", exists);
    regTestCompareValues(rp, 1, exists, 0.0);  /* 18 */

    fprintf(stderr, "\n ===================================================\n");
    fprintf(stderr, " ======= Test lept_mv(), lept_cp(), lept_rm() ======\n");
    fprintf(stderr, " ===================================================");
    TestLeptCpRm(rp, "weasel2.png", NULL, NULL);  /* 19 - 22 */
    TestLeptCpRm(rp, "weasel2.png", "junkfiles", NULL);  /* 23 - 26 */
    TestLeptCpRm(rp, "weasel2.png", NULL, "new_weasel2.png");  /* 27 - 30 */
    TestLeptCpRm(rp, "weasel2.png", "junkfiles", "new_weasel2.png"); /* 31-34 */

    fprintf(stderr, "\n ===================================================\n");
    fprintf(stderr, " =============== Test genPathname() ================\n");
    fprintf(stderr, " ===================================================\n");
    TestGenPathname(rp, "what/", NULL, "what");  /* 35 */
    TestGenPathname(rp, "what", "abc", "what/abc");  /* 36 */
    TestGenPathname(rp, NULL, "abc/def", "abc/def");  /* 37 */
    TestGenPathname(rp, "", "abc/def", "abc/def");  /* 38 */
#ifndef _WIN32   /* unix only */
    TestGenPathname(rp, "/tmp", NULL, "/tmp");  /* 39 */
    TestGenPathname(rp, "/tmp/", NULL, "/tmp");  /* 40 */
    TestGenPathname(rp, "/tmp/junk", NULL, "/tmp/junk");  /* 41 */
    TestGenPathname(rp, "/tmp/junk/abc", NULL, "/tmp/junk/abc");  /* 42 */
    TestGenPathname(rp, "/tmp/junk/", NULL, "/tmp/junk");  /* 43 */
    TestGenPathname(rp, "/tmp/junk", "abc", "/tmp/junk/abc");  /* 44 */
#endif  /* !_WIN32 */

    return regTestCleanup(rp);
}
Ejemplo n.º 11
0
void TestLeptCpRm(L_REGPARAMS  *rp,
                  const char   *srctail,
                  const char   *newdir,
                  const char   *newtail)
{
char     realnewdir[256], newnewdir[256];
char    *realtail, *newsrc, *fname;
l_int32  nfiles1, nfiles2, nfiles3;
SARRAY  *sa;

        /* Remove old version if it exists */
    realtail = (newtail) ? stringNew(newtail) : stringNew(srctail);
    lept_rm(newdir, realtail);
    makeTempDirname(realnewdir, 256, newdir);
    if (rp->display) {
        fprintf(stderr, "\nInput: srctail = %s, newdir = %s, newtail = %s\n",
                srctail, newdir, newtail);
        fprintf(stderr, "  realnewdir = %s, realtail = %s\n",
                realnewdir, realtail);
    }
    sa = getFilenamesInDirectory(realnewdir);
    nfiles1 = sarrayGetCount(sa);
    sarrayDestroy(&sa);

        /* Copy */
    lept_cp(srctail, newdir, newtail, &fname);
    sa = getFilenamesInDirectory(realnewdir);
    nfiles2 = sarrayGetCount(sa);
    if (rp->display) {
        fprintf(stderr, "  File copied to directory: %s\n", realnewdir);
        fprintf(stderr, "  ... with this filename: %s\n", fname);
        fprintf(stderr, "  delta files should be 1: %d\n", nfiles2 - nfiles1);
    }
    regTestCompareValues(rp, 1, nfiles2 - nfiles1, 0.0);  /* '1' */
    sarrayDestroy(&sa);
    lept_free(fname);

        /* Remove it */
    lept_rm(newdir, realtail);
    sa = getFilenamesInDirectory(realnewdir);
    nfiles2 = sarrayGetCount(sa);
    if (rp->display) {
        fprintf(stderr, "  File removed from directory: %s\n", realnewdir);
        fprintf(stderr, "  delta files should be 0: %d\n", nfiles2 - nfiles1);
    }
    regTestCompareValues(rp, 0, nfiles2 - nfiles1, 0.0);  /* '2' */
    sarrayDestroy(&sa);

        /* Copy it again ... */
    lept_cp(srctail, newdir, newtail, &fname);
    if (rp->display)
        fprintf(stderr, "  File copied to: %s\n", fname);

        /* move it elsewhere ... */
    lept_rmdir("junko");  /* clear out this directory */
    lept_mkdir("junko");
    newsrc = pathJoin(realnewdir, realtail);
    lept_mv(newsrc, "junko", NULL, &fname);
    if (rp->display) {
        fprintf(stderr, "  Move file at: %s\n", newsrc);
        fprintf(stderr, "  ... to: %s\n", fname);
    }
    lept_free(fname);
    lept_free(newsrc);
    makeTempDirname(newnewdir, 256, "junko");
    if (rp->display) fprintf(stderr, "  In this directory: %s\n", newnewdir);
    sa = getFilenamesInDirectory(newnewdir);  /* check if it landed ok */
    nfiles3 = sarrayGetCount(sa);
    if (rp->display) fprintf(stderr, "  num files should be 1: %d\n", nfiles3);
    regTestCompareValues(rp, 1, nfiles3, 0.0);  /* '3' */
    sarrayDestroy(&sa);

        /* and verify it was removed from the original location */
    sa = getFilenamesInDirectory(realnewdir);  /* check if it was removed */
    nfiles2 = sarrayGetCount(sa);
    if (rp->display) {
        fprintf(stderr, "  In this directory: %s\n", realnewdir);
        fprintf(stderr, "  delta files should be 0: %d\n", nfiles2 - nfiles1);
    }
    regTestCompareValues(rp, 0, nfiles2 - nfiles1, 0.0);  /* '4' */
    sarrayDestroy(&sa);
    lept_free(realtail);
}
Ejemplo n.º 12
0
/*!
 *  dewarpDebug()
 *
 *      Input:  dew
 *              subdirs (one or more subdirectories of /tmp; e.g., "dew1")
 *              index (to help label output images; e.g., the page number)
 *      Return: 0 if OK, 1 on error
 *
 *  Notes:
 *      (1) Prints dewarp fields and generates disparity array contour images.
 *          The contour images are written to file:
 *                /tmp/[subdirs]/pixv_[index].png
 */
l_int32
dewarpDebug(L_DEWARP    *dew,
            const char  *subdirs,
            l_int32      index)
{
char     fname[64];
char    *outdir, *pathname;
l_int32  svd, shd;
PIX     *pixv, *pixh;

    PROCNAME("dewarpDebug");

    if (!dew)
        return ERROR_INT("dew not defined", procName, 1);
    if (!subdirs)
        return ERROR_INT("subdirs not defined", procName, 1);

    fprintf(stderr, "pageno = %d, hasref = %d, refpage = %d\n",
            dew->pageno, dew->hasref, dew->refpage);
    fprintf(stderr, "sampling = %d, redfactor = %d, minlines = %d\n",
            dew->sampling, dew->redfactor, dew->minlines);
    svd = shd = 0;
    if (!dew->hasref) {
        if (dew->sampvdispar) svd = 1;
        if (dew->samphdispar) shd = 1;
        fprintf(stderr, "sampv = %d, samph = %d\n", svd, shd);
        fprintf(stderr, "w = %d, h = %d\n", dew->w, dew->h);
        fprintf(stderr, "nx = %d, ny = %d\n", dew->nx, dew->ny);
        fprintf(stderr, "nlines = %d\n", dew->nlines);
        if (svd) {
            fprintf(stderr, "(min,max,abs-diff) line curvature = (%d,%d,%d)\n",
                    dew->mincurv, dew->maxcurv, dew->maxcurv - dew->mincurv);
        }
        if (shd) {
            fprintf(stderr, "(left edge slope = %d, right edge slope = %d\n",
                    dew->leftslope, dew->rightslope);
            fprintf(stderr, "(left,right,abs-diff) edge curvature = "
                    "(%d,%d,%d)\n", dew->leftcurv, dew->rightcurv,
                    L_ABS(dew->leftcurv - dew->rightcurv));
        }
    }
    if (!svd && !shd) {
        fprintf(stderr, "No disparity arrays\n");
        return 0;
    }

    dewarpPopulateFullRes(dew, NULL, 0, 0);
    lept_mkdir(subdirs);
    outdir = pathJoin("/tmp", subdirs);
    if (svd) {
        pixv = fpixRenderContours(dew->fullvdispar, 3.0, 0.15);
        snprintf(fname, sizeof(fname), "pixv_%d.png", index);
        pathname = genPathname(outdir, fname);
        pixWrite(pathname, pixv, IFF_PNG);
        pixDestroy(&pixv);
        LEPT_FREE(pathname);
    }
    if (shd) {
        pixh = fpixRenderContours(dew->fullhdispar, 3.0, 0.15);
        snprintf(fname, sizeof(fname), "pixh_%d.png", index);
        pathname = genPathname(outdir, fname);
        pixWrite(pathname, pixh, IFF_PNG);
        pixDestroy(&pixh);
        LEPT_FREE(pathname);
    }
    LEPT_FREE(outdir);
    return 0;
}
Ejemplo n.º 13
0
            for (int ptr = 0; ptr < size; ptr ++)
            {
                *(data ++) = (map->mMetaTiles[ptr].blockmask & mask) != 0 ?
                    0x0 : 0x00ffffff;
            }

            SDL_UnlockSurface(surface);

            mMapImage = imageHelper->loadSurface(surface);
            mMapImage->setAlpha(settings.guiAlpha);
            mCustomMapImage = true;
            MSDL_FreeSurface(surface);
        }
        else
        {
            std::string tempname = pathJoin(paths.getStringValue("minimaps"),
                map->getFilename()).append(".png");

            std::string minimapName = map->getProperty("minimap",
                std::string());

            if (minimapName.empty() && VirtFs::exists(tempname))
                minimapName = tempname;

            if (minimapName.empty())
            {
                tempname = pathJoin("graphics/minimaps",
                    map->getFilename()).append(".png");
                if (VirtFs::exists(tempname))
                    minimapName = STD_MOVE(tempname);
            }