Exemplo n.º 1
0
static void action_move(const char *filename)
{
    char *nuname, *txt;
    FILE *f;

    if (!getdest(filename, &nuname))
        return;

    if (cw_movefile(filename, nuname, 0))
        logg("~%s: moved to '%s'\n", PATH_PLAIN(filename), PATH_PLAIN(nuname));
    else
        notmoved++;

    /* write a txt with the original location to being able to restore the file */
    if ((txt = malloc(strlen(nuname) + 5)))
    {
        strcpy(txt, nuname);
        strcat(txt, ".txt");

        if ((f = fopen(txt, "w")))
        {
            if (fprintf(f, "%s\t%s", filename, nuname) != (strlen(filename) + 1 + strlen(nuname)))
                logg("!Unable to write quaratine information file %s\n", strerror(errno));
            fclose(f);
        }
        else
            logg("!Unable to write quaratine information file %s\n", strerror(errno));

        free(txt);
    }
    else
        logg("!Unable to allocate memory for quaratine information file\n");

    free(nuname);
}
Exemplo n.º 2
0
static void action_copy(const char *filename)
{
    char *nuname;
    if (!getdest(filename, &nuname)) return;
    if (CopyFileA(filename, nuname, FALSE))
        logg("~%s: copied to '%s'\n", PATH_PLAIN(filename), PATH_PLAIN(nuname));
    else
    {
        logg("!Cannot copy file %s (%lu)\n", PATH_PLAIN(filename), GetLastError());
        notmoved++;
    }
    free(nuname);
}
Exemplo n.º 3
0
static void action_copy(const char *filename) {
    char *nuname;
    int fd = getdest(filename, &nuname);

    if(fd < 0 || filecopy(filename, nuname)) {
	logg("!Can't copy file '%s'\n", filename);
	notmoved++;
	if(nuname) unlink(nuname);
    } else
	logg("~%s: copied to '%s'\n", filename, nuname);

    if(fd>=0) close(fd);
    if(nuname) free(nuname);
}
Exemplo n.º 4
0
static void action_move(const char *filename) {
    char *nuname;
    int fd = getdest(filename, &nuname), copied = 0;

    if(fd<0 || (rename(filename, nuname) && (copied=1) && filecopy(filename, nuname))) {
	logg("!Can't move file %s\n", filename);
	notmoved++;
	if(nuname) unlink(nuname);
    } else {
	if(copied && unlink(filename))
	    logg("!Can't unlink '%s': %s\n", filename, strerror(errno));
	else
	    logg("~%s: moved to '%s'\n", filename, nuname);
    }

    if(fd>=0) close(fd);
    if(nuname) free(nuname);
}
Exemplo n.º 5
0
void fun_inc ()
{
    register VAR_ *dest = getdest();

    intSetValue(dest, intValue(dest) + 1);
}
Exemplo n.º 6
0
int is_mov(int v) {
    if (ISMEM(getsource(v)) && ISMEM(getdest(v))) return 0; ///BOTH SOURCE AND DEST CAN'T BE MEMORY
    return ((v >> 6) & 0x03) == 0x01;
}