#endif
#include <vlc_common.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
#include <vlc_strings.h>
#include <vlc_block.h>
/* */
char *vout_snapshot_GetDirectory(void)
{
- 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;
+ return config_GetUserDir(VLC_PICTURES_DIR);
}
/* */
int vout_snapshot_SaveImage(char **name, int *sequential,
{
/* */
char *filename;
- DIR *pathdir = utf8_opendir(cfg->path);
+ DIR *pathdir = vlc_opendir(cfg->path);
if (pathdir != NULL) {
/* The use specified a directory path */
closedir(pathdir);
char *prefix = NULL;
if (cfg->prefix_fmt)
prefix = str_format(object, cfg->prefix_fmt);
- if (!prefix) {
+ if (prefix)
+ filename_sanitize(prefix);
+ else {
prefix = strdup("vlcsnap-");
if (!prefix)
goto error;
free(prefix);
goto error;
}
- if (utf8_stat(filename, &st)) {
+ if (vlc_stat(filename, &st)) {
*sequential = num;
break;
}
goto error;
/* Save the snapshot */
- FILE *file = utf8_fopen(filename, "wb");
+ FILE *file = vlc_fopen(filename, "wb");
if (!file) {
msg_Err(object, "Failed to open '%s'", filename);
free(filename);