Esempio n. 1
0
void filestuff::copyDir(QString src, QString dest)
{
    exMake(dest);
    QDir srcDir(src);
    QDir destDir(dest);
    QStringList srcList(srcDir.entryList(QDir::Files));
    for (int i = 0; i < srcList.count(); i++){
        QString srcName(src + "/" + srcList[i]);
        QString destName(dest + "/" + srcList[i]);
        QFile::copy(srcName, destName);
    }
    srcList.clear();
    srcList = srcDir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
    for (int i = 0; i < srcList.count(); i++){
        QString srcName(src + "/" + srcList[i]);
        QString destName(dest + "/" + srcList[i]);
        copyDir(srcName, destName);
    }
}
Esempio n. 2
0
void LinkHandler::LaunchFile(const WCHAR *path, PageDestination *link)
{
    // for safety, only handle relative paths and only open them in SumatraPDF
    // (unless they're of an allowed perceived type) and never launch any external
    // file in plugin mode (where documents are supposed to be self-contained)
    WCHAR drive;
    if (str::StartsWith(path, L"\\") || str::Parse(path, L"%c:\\", &drive) || gPluginMode) {
        return;
    }

    // TODO: link is deleted when opening the document in a new tab
    RemoteDestination *remoteLink = NULL;
    if (link) {
        remoteLink = new RemoteDestination(link);
        link = NULL;
    }

    ScopedMem<WCHAR> fullPath(path::GetDir(owner->ctrl->FilePath()));
    fullPath.Set(path::Join(fullPath, path));
    fullPath.Set(path::Normalize(fullPath));
    // TODO: respect link->ld.gotor.new_window for PDF documents ?
    WindowInfo *newWin = FindWindowInfoByFile(fullPath, true);
    // TODO: don't show window until it's certain that there was no error
    if (!newWin) {
        LoadArgs args(fullPath, owner);
        newWin = LoadDocument(args);
        if (!newWin) {
            delete remoteLink;
            return;
        }
    }

    if (!newWin->IsDocLoaded()) {
        CloseTab(newWin);
        // OpenFileExternally rejects files we'd otherwise
        // have to show a notification to be sure (which we
        // consider bad UI and thus simply don't)
        bool ok = OpenFileExternally(fullPath);
        if (!ok) {
            ScopedMem<WCHAR> msg(str::Format(_TR("Error loading %s"), fullPath));
            owner->ShowNotification(msg, true /* autoDismiss */, true /* highlight */);
        }
        delete remoteLink;
        return;
    }

    newWin->Focus();
    if (!remoteLink)
        return;

    ScopedMem<WCHAR> destName(remoteLink->GetDestName());
    if (destName) {
        PageDestination *dest = newWin->ctrl->GetNamedDest(destName);
        if (dest) {
            newWin->linkHandler->ScrollTo(dest);
            delete dest;
        }
    }
    else {
        newWin->linkHandler->ScrollTo(remoteLink);
    }
    delete remoteLink;
}