Change a few instances of 'stat()' to use 'g_stat()' (for UTF8 compatibility on Windows)

This commit is contained in:
John Emmas 2015-10-04 14:18:54 +01:00
parent cf33204e35
commit c68736bc02
5 changed files with 22 additions and 21 deletions

View File

@ -28,6 +28,7 @@
#include <cstdlib>
#include <ctime>
#include <pbd/gstdio_compat.h>
#include "pbd/error.h"
#include "pbd/xml++.h"
#include "pbd/memento_command.h"
@ -2284,8 +2285,8 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
}
// This protects sessions from errant CapturingSources in stored sessions
struct stat sbuf;
if (stat (prop->value().c_str(), &sbuf)) {
GStatBuf sbuf;
if (g_stat (prop->value().c_str(), &sbuf)) {
continue;
}

View File

@ -18,12 +18,13 @@
*/
#include <unistd.h>
#include <sys/stat.h>
#include <cstring>
#include <climits>
#include <cerrno>
#include <pbd/gstdio_compat.h>
#include <glibmm/miscutils.h>
#include "pbd/compose.h"
@ -44,7 +45,7 @@ namespace ARDOUR {
int
find_session (string str, string& path, string& snapshot, bool& isnew)
{
struct stat statbuf;
GStatBuf statbuf;
isnew = false;
@ -52,7 +53,7 @@ find_session (string str, string& path, string& snapshot, bool& isnew)
/* check to see if it exists, and what it is */
if (stat (str.c_str(), &statbuf)) {
if (g_stat (str.c_str(), &statbuf)) {
if (errno == ENOENT) {
isnew = true;
} else {
@ -81,7 +82,7 @@ find_session (string str, string& path, string& snapshot, bool& isnew)
/* is it there ? */
if (stat (tmp.c_str(), &statbuf)) {
if (g_stat (tmp.c_str(), &statbuf)) {
error << string_compose (_("cannot check statefile %1 (%2)"), tmp, strerror (errno))
<< endmsg;
return -1;

View File

@ -31,7 +31,6 @@
#include <cstdio> /* snprintf(3) ... grrr */
#include <cmath>
#include <unistd.h>
#include <sys/stat.h>
#include <climits>
#include <signal.h>
#include <sys/time.h>
@ -3065,7 +3064,7 @@ Session::cleanup_sources (CleanupReport& rep)
/* now try to move all unused files into the "dead" directory(ies) */
for (vector<string>::iterator x = unused.begin(); x != unused.end(); ++x) {
struct stat statbuf;
GStatBuf statbuf;
string newpath;
@ -3130,7 +3129,7 @@ Session::cleanup_sources (CleanupReport& rep)
}
stat ((*x).c_str(), &statbuf);
g_stat ((*x).c_str(), &statbuf);
if (::rename ((*x).c_str(), newpath.c_str()) != 0) {
error << string_compose (_("cannot rename unused file source from %1 to %2 (%3)"),
@ -3161,8 +3160,8 @@ Session::cleanup_sources (CleanupReport& rep)
}
rep.paths.push_back (*x);
rep.space += statbuf.st_size;
}
rep.space += statbuf.st_size;
}
/* dump the history list */

View File

@ -33,7 +33,6 @@
#include <cerrno>
#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#ifndef COMPILER_MSVC
@ -42,6 +41,8 @@
#include <errno.h>
#include <regex.h>
#include <pbd/gstdio_compat.h>
#include <glibmm/miscutils.h>
#include <glibmm/fileutils.h>
@ -662,11 +663,11 @@ ARDOUR::native_header_format_extension (HeaderFormat hf, const DataType& type)
bool
ARDOUR::matching_unsuffixed_filename_exists_in (const string& dir, const string& path)
{
string bws = basename_nosuffix (path);
string bws = basename_nosuffix (path);
struct dirent* dentry;
struct stat statbuf;
GStatBuf statbuf;
DIR* dead;
bool ret = false;
bool ret = false;
if ((dead = ::opendir (dir.c_str())) == 0) {
error << string_compose (_("cannot open directory %1 (%2)"), dir, strerror (errno)) << endl;
@ -684,7 +685,7 @@ ARDOUR::matching_unsuffixed_filename_exists_in (const string& dir, const string&
string fullpath = Glib::build_filename (dir, dentry->d_name);
if (::stat (fullpath.c_str(), &statbuf)) {
if (g_stat (fullpath.c_str(), &statbuf)) {
continue;
}

View File

@ -27,7 +27,6 @@
#include <cassert>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
@ -419,11 +418,11 @@ vstfx_infofile_for_read (const char* dllpath)
string const path = vstfx_infofile_path (dllpath);
if (Glib::file_test (path, Glib::FileTest (Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_REGULAR))) {
struct stat dllstat;
struct stat fsistat;
GStatBuf dllstat;
GStatBuf fsistat;
if (stat (dllpath, &dllstat) == 0) {
if (stat (path.c_str (), &fsistat) == 0) {
if (g_stat (dllpath, &dllstat) == 0) {
if (g_stat (path.c_str (), &fsistat) == 0) {
if (dllstat.st_mtime <= fsistat.st_mtime) {
/* plugin is older than info file */
return g_fopen (path.c_str (), "rb");