当前位置: 首页>>代码示例>>C++>>正文


C++ ExtensionString类代码示例

本文整理汇总了C++中ExtensionString的典型用法代码示例。如果您正苦于以下问题:C++ ExtensionString类的具体用法?C++ ExtensionString怎么用?C++ ExtensionString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ExtensionString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ShowSaveDialog

int32 ShowSaveDialog(ExtensionString title,
                     ExtensionString initialDirectory,
                     ExtensionString proposedNewFilename,
                     ExtensionString& newFilePath)
{
    GtkWidget *openSaveDialog;
    
    openSaveDialog = gtk_file_chooser_dialog_new(title.c_str(),
        NULL,
        GTK_FILE_CHOOSER_ACTION_SAVE,
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
        GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
        NULL);
    
    gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (openSaveDialog), TRUE);	
    if (!initialDirectory.empty())
    {
        gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (openSaveDialog), proposedNewFilename.c_str());
        
        ExtensionString folderURI = std::string("file:///") + initialDirectory;
        gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (openSaveDialog), folderURI.c_str());
    }
    
    if (gtk_dialog_run (GTK_DIALOG (openSaveDialog)) == GTK_RESPONSE_ACCEPT)
    {
        char* filePath;
        filePath = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (openSaveDialog));
        newFilePath = filePath;
        g_free (filePath);
    }
    
    gtk_widget_destroy (openSaveDialog);
    return NO_ERROR;
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:34,代码来源:appshell_extensions_gtk.cpp

示例2: fixupKey

//Replace keyStroke with replaceString 
bool fixupKey(ExtensionString& key, ExtensionString keyStroke, ExtensionString replaceString)
{
	size_t idx = key.find(keyStroke, 0);
	if (idx != ExtensionString::npos) {
		key = key.replace(idx, keyStroke.size(), replaceString);
		return true;
	}
	return false;
}
开发者ID:116356754,项目名称:brackets-shell,代码行数:10,代码来源:appshell_extensions.cpp

示例3: HasSwitch

// CefCommandLine::HasSwitch is unable to report the presense of switches,
// in the command line properly. This is a generic function that could be
// used to check for any particular switch, passed as a command line argument.
bool HasSwitch(CefRefPtr<CefCommandLine> command_line , CefString& switch_name)
{
  if (command_line) {
    ExtensionString cmdLine = command_line->GetCommandLineString();
    size_t idx = cmdLine.find(switch_name);
    return idx > 0 && idx < cmdLine.length();
  } else {
    return false;
  }
}
开发者ID:adobe,项目名称:brackets-shell,代码行数:13,代码来源:cefclient.cpp

示例4: Rename

int Rename(ExtensionString oldName, ExtensionString newName)
{
    const char *newNameStr = newName.c_str();

    if (g_file_test(newNameStr, G_FILE_TEST_EXISTS)) {
        return ERR_FILE_EXISTS;
    }

    if (rename(oldName.c_str(), newNameStr) == -1) {
        return ConvertLinuxErrorCode(errno);
    }
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:12,代码来源:appshell_extensions_gtk.cpp

示例5: DeleteFileOrDirectory

int32 DeleteFileOrDirectory(ExtensionString filename)
{
    DWORD dwAttr = GetFileAttributes(filename.c_str());

    if (dwAttr == INVALID_FILE_ATTRIBUTES)
        return ERR_NOT_FOUND;

    if ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0)
        return ERR_NOT_FILE;

    if (!DeleteFile(filename.c_str()))
        return ConvertWinErrorCode(GetLastError());

    return NO_ERROR;
}
开发者ID:artjumble,项目名称:brackets-shell,代码行数:15,代码来源:appshell_extensions_win.cpp

示例6: OpenURLInDefaultBrowser

int32 OpenURLInDefaultBrowser(ExtensionString url)
{
    GError* error = NULL;
    gtk_show_uri(NULL, url.c_str(), GDK_CURRENT_TIME, &error);
    g_error_free(error);
    return NO_ERROR;
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:7,代码来源:appshell_extensions_gtk.cpp

示例7: WriteFile

int32 WriteFile(ExtensionString filename, std::string contents, ExtensionString encoding)
{
    const char *filenameStr = filename.c_str();    
    int error = NO_ERROR;
    GError *gerror = NULL;

    if (encoding != "utf8") {
        return ERR_UNSUPPORTED_ENCODING;
    } else if (g_file_test(filenameStr, G_FILE_TEST_EXISTS) && g_access(filenameStr, W_OK) == -1) {
        return ERR_CANT_WRITE;
    }
    
    FILE* file = fopen(filenameStr, "w");
    if (file) {
        size_t size = fwrite(contents.c_str(), sizeof(gchar), contents.length(), file);
        if (size != contents.length()) {
            error = ERR_CANT_WRITE;
        }

        fclose(file);
    } else {
        return ConvertLinuxErrorCode(errno);
    }

    return error;
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:26,代码来源:appshell_extensions_gtk.cpp

示例8: CopyFile

int32 CopyFile(ExtensionString src, ExtensionString dest)
{
    int error = NO_ERROR;
    GFile *source = g_file_new_for_path(src.c_str());
    GFile *destination = g_file_new_for_path(dest.c_str());
    GError *gerror = NULL;

    if (!g_file_copy(source, destination, (GFileCopyFlags)(G_FILE_COPY_OVERWRITE|G_FILE_COPY_NOFOLLOW_SYMLINKS|G_FILE_COPY_TARGET_DEFAULT_PERMS), NULL, NULL, NULL, &gerror)) {
        error = ConvertGnomeErrorCode(gerror);
        g_error_free(gerror);
    }
    g_object_unref(source);
    g_object_unref(destination);

    return error;    
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:16,代码来源:appshell_extensions_gtk.cpp

示例9: SetPosixPermissions

int SetPosixPermissions(ExtensionString filename, int32 mode)
{
    if (chmod(filename.c_str(),mode) == -1) {
        return ConvertLinuxErrorCode(errno);
    }

    return NO_ERROR;
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:8,代码来源:appshell_extensions_gtk.cpp

示例10: DeleteFileOrDirectory

int DeleteFileOrDirectory(ExtensionString filename)
{
    GFile *file = g_file_new_for_path(filename.c_str());
    int error = _doDeleteFileOrDirectory(file);
    g_object_unref(file);

    return error;
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:8,代码来源:appshell_extensions_gtk.cpp

示例11: ReadDir

int32 ReadDir(ExtensionString path, CefRefPtr<CefListValue>& directoryContents)
{
    if (path.length() && path[path.length() - 1] != '/')
        path += '/';

    path += '*';

    WIN32_FIND_DATA ffd;
    HANDLE hFind = FindFirstFile(path.c_str(), &ffd);

    std::vector<ExtensionString> resultFiles;
    std::vector<ExtensionString> resultDirs;

    if (hFind != INVALID_HANDLE_VALUE) {
        do {
            // Ignore '.' and '..'
            if (!wcscmp(ffd.cFileName, L".") || !wcscmp(ffd.cFileName, L".."))
                continue;

            // Collect file and directory names separately
            if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
                resultDirs.push_back(ExtensionString(ffd.cFileName));
            } else {
                resultFiles.push_back(ExtensionString(ffd.cFileName));
            }
        }
        while (FindNextFile(hFind, &ffd) != 0);

        FindClose(hFind);
    } 
    else {
        return ConvertWinErrorCode(GetLastError());
    }

    // On Windows, list directories first, then files
    size_t i, total = 0;
    for (i = 0; i < resultDirs.size(); i++)
        directoryContents->SetString(total++, resultDirs[i]);
    for (i = 0; i < resultFiles.size(); i++)
        directoryContents->SetString(total++, resultFiles[i]);

    return NO_ERROR;
}
开发者ID:artjumble,项目名称:brackets-shell,代码行数:43,代码来源:appshell_extensions_win.cpp

示例12: GetFileModificationTime

int32 GetFileModificationTime(ExtensionString filename, uint32& modtime, bool& isDir)
{
    DWORD dwAttr = GetFileAttributes(filename.c_str());

    if (dwAttr == INVALID_FILE_ATTRIBUTES) {
        return ConvertWinErrorCode(GetLastError()); 
    }

    isDir = ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0);

    WIN32_FILE_ATTRIBUTE_DATA   fad;
    if (!GetFileAttributesEx(filename.c_str(), GetFileExInfoStandard, &fad)) {
        return ConvertWinErrorCode(GetLastError());
    }

    modtime = FiletimeToTime(fad.ftLastWriteTime);

    return NO_ERROR;
}
开发者ID:artjumble,项目名称:brackets-shell,代码行数:19,代码来源:appshell_extensions_win.cpp

示例13: OpenURLInDefaultBrowser

int32 OpenURLInDefaultBrowser(ExtensionString url)
{
    DWORD result = (DWORD)ShellExecute(NULL, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);

    // If the result > 32, the function suceeded. If the result is <= 32, it is an
    // error code.
    if (result <= 32)
        return ConvertWinErrorCode(result);

    return NO_ERROR;
}
开发者ID:artjumble,项目名称:brackets-shell,代码行数:11,代码来源:appshell_extensions_win.cpp

示例14: SetPosixPermissions

int32 SetPosixPermissions(ExtensionString filename, int32 mode)
{
    DWORD dwAttr = GetFileAttributes(filename.c_str());

    if (dwAttr == INVALID_FILE_ATTRIBUTES)
        return ERR_NOT_FOUND;

    if ((dwAttr & FILE_ATTRIBUTE_DIRECTORY) != 0)
        return NO_ERROR;

    bool write = (mode & 0200) != 0; 
    bool read = (mode & 0400) != 0;
    int mask = (write ? _S_IWRITE : 0) | (read ? _S_IREAD : 0);

    if (_wchmod(filename.c_str(), mask) == -1) {
        return ConvertErrnoCode(errno); 
    }

    return NO_ERROR;
}
开发者ID:artjumble,项目名称:brackets-shell,代码行数:20,代码来源:appshell_extensions_win.cpp

示例15: AddMenuItem

int32 AddMenuItem(CefRefPtr<CefBrowser> browser, ExtensionString parentCommand, ExtensionString itemTitle,
                  ExtensionString command, ExtensionString key, ExtensionString displayStr,
                  ExtensionString position, ExtensionString relativeId)
{
    GtkWidget* entry = gtk_menu_item_new_with_label(itemTitle.c_str());
    g_signal_connect(entry, "activate", FakeCallback, NULL);
    // FIXME add lookup for menu widgets
    gtk_menu_shell_append(GTK_MENU_SHELL(_menuWidget), entry);
    gtk_widget_show(entry);

    return NO_ERROR;
}
开发者ID:ChaosDeSelva,项目名称:brackets-shell,代码行数:12,代码来源:appshell_extensions_gtk.cpp


注:本文中的ExtensionString类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。