void FileConfigControl::updateField() { QString file = QFileDialog::getOpenFileName( NULL, qtr( "Select File" ), qfu( config_GetHomeDir() ) ); if( file.isNull() ) return; text->setText( toNativeSeparators( file ) ); }
char *config_GetUserDir (vlc_userdir_t type) { switch (type) { case VLC_HOME_DIR: break; case VLC_CONFIG_DIR: return config_GetAppDir ("CONFIG", ".config"); case VLC_DATA_DIR: return config_GetAppDir ("DATA", ".local/share"); case VLC_CACHE_DIR: return config_GetAppDir ("CACHE", ".cache"); case VLC_DESKTOP_DIR: return config_GetTypeDir ("DESKTOP"); case VLC_DOWNLOAD_DIR: return config_GetTypeDir ("DOWNLOAD"); case VLC_TEMPLATES_DIR: return config_GetTypeDir ("TEMPLATES"); case VLC_PUBLICSHARE_DIR: return config_GetTypeDir ("PUBLICSHARE"); case VLC_DOCUMENTS_DIR: return config_GetTypeDir ("DOCUMENTS"); case VLC_MUSIC_DIR: return config_GetTypeDir ("MUSIC"); case VLC_PICTURES_DIR: return config_GetTypeDir ("PICTURES"); case VLC_VIDEOS_DIR: return config_GetTypeDir ("VIDEOS"); } return config_GetHomeDir (); }
void DirectoryConfigControl::updateField() { QString dir = QFileDialog::getExistingDirectory( NULL, qtr( "Select Directory" ), text->text().isEmpty() ? qfu( config_GetHomeDir() ) : text->text(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); if( dir.isNull() ) return; text->setText( toNativeSepNoSlash( dir ) ); }
static char *getAppDependentDir(vlc_userdir_t type) { const char *psz_path; switch (type) { case VLC_CONFIG_DIR: psz_path = "%s/Library/Preferences/%s"; break; case VLC_TEMPLATES_DIR: case VLC_DATA_DIR: psz_path = "%s/Library/Application Support/%s"; break; case VLC_CACHE_DIR: psz_path = "%s/Library/Caches/%s"; break; default: assert(0); break; } // Default fallback const char *name = "org.videolan.vlc"; CFBundleRef mainBundle = CFBundleGetMainBundle(); if (mainBundle) { CFStringRef identifierAsNS = CFBundleGetIdentifier(mainBundle); if (identifierAsNS) { char identifier[256]; Boolean ret = CFStringGetCString(identifierAsNS, identifier, sizeof(identifier), kCFStringEncodingUTF8); if (ret) name = identifier; } } char *psz_parent = config_GetHomeDir (); char *psz_dir; if( asprintf( &psz_dir, psz_path, psz_parent, name) == -1 ) psz_dir = NULL; free(psz_parent); return psz_dir; }
char *config_GetUserDir (vlc_userdir_t type) { const char *psz_path; switch (type) { case VLC_CONFIG_DIR: case VLC_TEMPLATES_DIR: case VLC_DATA_DIR: case VLC_CACHE_DIR: return getAppDependentDir(type); case VLC_DESKTOP_DIR: psz_path = "%s/Desktop"; break; case VLC_DOWNLOAD_DIR: psz_path = "%s/Downloads"; break; case VLC_DOCUMENTS_DIR: psz_path = "%s/Documents"; break; case VLC_MUSIC_DIR: psz_path = "%s/Music"; break; case VLC_PICTURES_DIR: psz_path = "%s/Pictures"; break; case VLC_VIDEOS_DIR: psz_path = "%s/Movies"; break; case VLC_PUBLICSHARE_DIR: psz_path = "%s/Public"; break; case VLC_HOME_DIR: default: psz_path = "%s"; } char *psz_parent = config_GetHomeDir (); char *psz_dir; if( asprintf( &psz_dir, psz_path, psz_parent ) == -1 ) psz_dir = NULL; free(psz_parent); return psz_dir; }
static char *config_GetAppDir (const char *xdg_name, const char *xdg_default) { char *psz_dir; char var[sizeof ("XDG__HOME") + strlen (xdg_name)]; /* XDG Base Directory Specification - Version 0.6 */ snprintf (var, sizeof (var), "XDG_%s_HOME", xdg_name); const char *home = getenv (var); if (home != NULL) { if (asprintf (&psz_dir, "%s/vlc", home) == -1) psz_dir = NULL; return psz_dir; } char *psz_home = config_GetHomeDir (); if( psz_home == NULL || asprintf( &psz_dir, "%s/%s/vlc", psz_home, xdg_default ) == -1 ) psz_dir = NULL; free (psz_home); return psz_dir; }
/* Check for updates */ void UpdateDialog::UpdateOrDownload() { if( !b_checked ) { updateButton->setEnabled( false ); updateLabelTop->setText( qtr( "Launching an update request..." ) ); update_Check( p_update, UpdateCallback, this ); } else { QString dest_dir = QFileDialog::getExistingDirectory( this, qtr( "Select a directory..." ), qfu( config_GetHomeDir() ) ); if( !dest_dir.isEmpty() ) { dest_dir = toNativeSepNoSlash( dest_dir ) + DIR_SEP; msg_Dbg( p_intf, "Downloading to folder: %s", qtu( dest_dir ) ); toggleVisible(); update_Download( p_update, qtu( dest_dir ) ); } } }
static void Trigger (access_t *access) { access_sys_t *p_sys = access->p_sys; if (p_sys->stream == NULL) return; // too late if (p_sys->tmp_max == -1) return; // already triggered - should we stop? FIXME time_t now; time (&now); struct tm t; if (localtime_r (&now, &t) == NULL) return; // No time, eh? Well, I'd rather not run on your computer. if (t.tm_year > 999999999) // Humanity is about 300 times older than when this was written, // and there is an off-by-one in the following sprintf(). return; const char *home = config_GetHomeDir(); /* Hmm what about the extension?? */ char filename[strlen (home) + sizeof ("/vlcdump-YYYYYYYYY-MM-DD-HH-MM-SS.ts")]; sprintf (filename, "%s/vlcdump-%04u-%02u-%02u-%02u-%02u-%02u.ts", home, t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec); msg_Info (access, "dumping media to \"%s\"...", filename); FILE *newstream = utf8_fopen (filename, "wb"); if (newstream == NULL) { msg_Err (access, "cannot create dump file \"%s\": %m", filename); return; } /* This might cause excessive hard drive work :( */ FILE *oldstream = p_sys->stream; rewind (oldstream); for (;;) { char buf[16384]; size_t len = fread (buf, 1, sizeof (buf), oldstream); if (len == 0) { if (ferror (oldstream)) { msg_Err (access, "cannot read temporary file: %m"); break; } /* Done with temporary file */ fclose (oldstream); p_sys->stream = newstream; p_sys->tmp_max = -1; return; } if (fwrite (buf, len, 1, newstream) != 1) { msg_Err (access, "cannot write dump file: %m"); break; } } /* Failed to copy temporary file */ fseek (oldstream, 0, SEEK_END); fclose (newstream); return; }
/** * This function will return the default directory used for snapshots */ static char *VoutSnapshotGetDefaultDirectory( vout_thread_t *p_vout ) { char *psz_path = NULL; #if defined(__APPLE__) || defined(SYS_BEOS) if( asprintf( &psz_path, "%s/Desktop", config_GetHomeDir() ) == -1 ) psz_path = NULL; #elif defined(WIN32) && !defined(UNDER_CE) /* Get the My Pictures folder path */ char *p_mypicturesdir = NULL; typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD, LPWSTR ); #ifndef CSIDL_FLAG_CREATE # define CSIDL_FLAG_CREATE 0x8000 #endif #ifndef CSIDL_MYPICTURES # define CSIDL_MYPICTURES 0x27 #endif #ifndef SHGFP_TYPE_CURRENT # define SHGFP_TYPE_CURRENT 0 #endif HINSTANCE shfolder_dll; SHGETFOLDERPATH SHGetFolderPath ; /* load the shfolder dll to retrieve SHGetFolderPath */ if( ( shfolder_dll = LoadLibrary( _T("SHFolder.dll") ) ) != NULL ) { wchar_t wdir[PATH_MAX]; SHGetFolderPath = (void *)GetProcAddress( shfolder_dll, _T("SHGetFolderPathW") ); if ((SHGetFolderPath != NULL ) && SUCCEEDED (SHGetFolderPath (NULL, CSIDL_MYPICTURES | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, wdir))) p_mypicturesdir = FromWide (wdir); FreeLibrary( shfolder_dll ); } if( p_mypicturesdir == NULL ) psz_path = strdup( config_GetHomeDir() ); else psz_path = p_mypicturesdir; #else /* XXX: This saves in the data directory. Shouldn't we try saving * to psz_homedir/Desktop or something nicer ? */ char *psz_datadir = config_GetUserDataDir(); if( psz_datadir ) { if( asprintf( &psz_path, "%s", psz_datadir ) == -1 ) psz_path = NULL; free( psz_datadir ); } #endif return psz_path; }