Example #1
0
void EDirectory::RescanList() {
    char Dir[256];
    char Name[256];
    int DirCount = 0;
    unsigned long SizeCount = 0;
    FileFind *ff;
    FileInfo *fi;
    int rc;

    if (Files)
        FreeList();

    Count = 0;
    FCount = 0;
    if (JustDirectory(Path, Dir, sizeof(Dir)) != 0) return;
    JustFileName(Path, Name, sizeof(Name));

    // we don't want any special information about symbolic links, just to browse files
    ff = new FileFind(Dir, "*", ffDIRECTORY | ffHIDDEN | ffLINK);
    if (ff == 0)
        return ;

    rc = ff->FindFirst(&fi);
    while (rc == 0) {
        assert(fi != 0);
        if (strcmp(fi->Name(), ".") != 0) {
            Files = (FileInfo **)realloc((void *)Files, ((FCount | 255) + 1) * sizeof(FileInfo *));
            if (Files == 0)
            {
                delete fi;
                delete ff;
                return;
            }

            Files[FCount] = fi;

            SizeCount += Files[FCount]->Size();
            if (fi->Type() == fiDIRECTORY && (strcmp(fi->Name(), "..") != 0))
                DirCount++;
            Count++;
            FCount++;
        } else
            delete fi;
        rc = ff->FindNext(&fi);
    }
    delete ff;

    {
        char CTitle[256];

        sprintf(CTitle, "%d files%c%d dirs%c%lu bytes%c%-200.200s",
                FCount, ConGetDrawChar(DCH_V),
                DirCount, ConGetDrawChar(DCH_V),
                SizeCount, ConGetDrawChar(DCH_V),
                Dir);
        SetTitle(CTitle);
    }
    qsort(Files, FCount, sizeof(FileInfo *), FileNameCmp);
    NeedsRedraw = 1;
}
Example #2
0
void EDirectory::GetInfo(char *AInfo, int /*MaxLen*/) {
    char buf[256] = {0};
    char winTitle[256] = {0};

    JustFileName(Path, buf, sizeof(buf));
    if (buf[0] == '\0') // if there is no filename, try the directory name.
        JustLastDirectory(Path, buf, sizeof(buf));

    if (buf[0] != 0) // if there is a file/dir name, stick it in here.
    {
        strncat(winTitle, buf, sizeof(winTitle) - 1 - strlen(winTitle));
        strncat(winTitle, "/ - ", sizeof(winTitle) - 1 - strlen(winTitle));
    }
    strncat(winTitle, Path, sizeof(winTitle) - 1 - strlen(winTitle));
    winTitle[sizeof(winTitle) - 1] = 0;

    sprintf(AInfo,
            "%2d %04d/%03d %-150s",
            ModelNo,
            Row + 1, FCount,
            winTitle);
/*    sprintf(AInfo,
            "%2d %04d/%03d %-150s",
            ModelNo,
            Row + 1, FCount,
            Path);*/
}
Example #3
0
int EDirectory::FmChDir(const char *Name) {
    char Dir[256];
    char CName[256] = "";

    if (strcmp(Name, SSLASH) == 0) {
        JustRoot(Path, Dir, sizeof(Dir));
    } else if (strcmp(Name, SDOT SDOT) == 0) {
        Slash(Path, 0);
        JustFileName(Path, CName, sizeof(CName));
        JustDirectory(Path, Dir, sizeof(Dir));
    } else {
        JustDirectory(Path, Dir, sizeof(Dir));
        Slash(Dir, 1);
        strlcat(Dir, Name, sizeof(Dir));
    }
    Slash(Dir, 1);
    free(Path);
    Path = strdup(Dir);
    Row = 0;
    RescanList();
    if (CName[0] != 0) {
        for (int i = 0; i < FCount; i++) {
            if (filecmp(Files[i]->Name(), CName) == 0)
            {
                Row = i;
                break;
            }
        }
    }
    UpdateTitle();
    return 1;
}
Example #4
0
int EView::CvsDiff(char *Options) {
    char Dir[MAXPATH] = "";
    char Command[256] = "";
    char buf[1024] = "";
    char *OnFiles = buf;
    ECvsDiff *diffs;

    if (GetDefaultDirectory(Model, Dir, sizeof(Dir)) == 0) return 0;

    strcpy(Command, CvsCommand);
    strcat(Command, " diff -c ");
    if (Options[0] != 0) {
        strcat(Command, Options);
        strcat(Command, " ");
    }

    switch (Model->GetContext()) {
    case CONTEXT_FILE:
        if (JustFileName(((EBuffer *)Model)->FileName, OnFiles, sizeof(buf)) != 0) return 0; // OnFiles points to buf
        break;
    case CONTEXT_CVSDIFF:
        OnFiles = strdup(CvsDiffView->OnFiles);
        break;
    case CONTEXT_CVS:
        OnFiles = ((ECvs *)Model)->MarkedAsList();
        if (!OnFiles) OnFiles = strdup(((ECvs *)Model)->OnFiles);
        break;
    }

    if (CvsDiffView != 0) {
        CvsDiffView->RunPipe(Dir, Command, OnFiles);
        diffs = CvsDiffView;
    } else {
        diffs = new ECvsDiff(0, &ActiveModel, Dir, Command, OnFiles);
    }
    if (OnFiles != buf) free(OnFiles);
    SwitchToModel(diffs);
    return 1;
}
Example #5
0
int EView::Svn(char *Options) {
    char Dir[MAXPATH] = "";
    char Command[256] = "";
    char buf[1024] = "";
    char *OnFiles = buf;
    ESvn *svn;

    if (GetDefaultDirectory(Model, Dir, sizeof(Dir)) == 0) return 0;

    strcpy(Command, SvnCommand);
    strcat(Command, " ");
    if (Options[0] != 0) {
        strcat(Command, Options);
        strcat(Command, " ");
    }

    switch (Model->GetContext()) {
    case CONTEXT_FILE:
        if (JustFileName(((EBuffer *)Model)->FileName, OnFiles, sizeof(buf)) != 0) return 0; // OnFiles points to buf
        break;
    case CONTEXT_SVNDIFF:
        OnFiles = strdup(SvnDiffView->OnFiles);
        break;
    case CONTEXT_SVN:
        OnFiles = ((ESvn *)Model)->MarkedAsList();
        if (!OnFiles) OnFiles = strdup(((ESvn *)Model)->OnFiles);
        break;
    }

    if (SvnView != 0) {
        SvnView->RunPipe(Dir, Command, OnFiles);
        svn = SvnView;
    } else {
        svn = new ESvn(0, &ActiveModel, Dir, Command, OnFiles);
    }
    if (OnFiles != buf) free(OnFiles);
    SwitchToModel(svn);
    return 1;
}
Example #6
0
int MultiFileLoad(int createFlags, const char *FileName, const char *Mode, EView *View) {
    char fX[MAXPATH];
    int count = 0;
    char FPath[MAXPATH];
    char FName[MAXPATH];
    FileFind *ff;
    FileInfo *fi;
    int rc;

    assert(View != 0);

    JustDirectory(FileName, fX, sizeof (fX));
    if (fX[0] == 0) strcpy(fX, ".");
    JustFileName(FileName, FName, sizeof(FName));
    if (ExpandPath(fX, FPath, sizeof(FPath)) == -1) return 0;
    Slash(FPath, 1);

    ff = new FileFind(FPath, FName, ffHIDDEN | ffFULLPATH);
    if (ff == 0)
        return 0;
    rc = ff->FindFirst(&fi);
    while (rc == 0) {
        count++;
        if (FileLoad(createFlags, fi->Name(), Mode, View) == 0) {
            delete fi;
            delete ff;
            return 0;
        }
        delete fi;
        rc = ff->FindNext(&fi);
    }
    delete ff;
    if (count == 0)
        return FileLoad(createFlags, FileName, Mode, View);
    return 1;
}