sys.cpp revision 6a5b303a37a021eeb46ed6d2679c022aba963fd2
/*
* System abstraction utility routines
*
* Authors:
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2004-2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <glibmm/fileutils.h>
#endif
#include <gtk/gtkmessagedialog.h>
#include "prefs-utils.h"
#include "sys.h"
#ifdef WIN32
// For now to get at is_os_wide().
#endif
//#define INK_DUMP_FILENAME_CONV 1
//#define INK_DUMP_FOPEN 1
extern guint update_in_progress;
#define DEBUG_MESSAGE(key, ...) \
{\
if ( dump )\
{\
g_message( __VA_ARGS__ );\
\
}\
if ( dumpD )\
{\
);\
dialog); \
}\
}
{
#ifdef INK_DUMP_FOPEN
for ( int i = 0; utf8name[i]; i++ )
{
if ( utf8name[i] == '\\' )
{
str += "\\\\";
}
{
}
else
{
}
}
#else
(void)utf8name;
(void)id;
#endif
}
{
#ifndef WIN32
if ( filename )
{
filename = 0;
}
#else
#endif
return fp;
}
{
int retval = -1;
#ifndef WIN32
if ( filename )
{
filename = 0;
}
#else
// Mode should be ingnored inside of glib on the way in
#endif
return retval;
}
/*
* Wrapper around Glib::file_open_tmp()
* Returns a handle to the temp file
* name_used contains the actual name used
*
* Returns:
* A file handle (as from open()) to the file opened for reading and writing.
* The file is opened in binary mode on platforms where there is a difference.
* The file handle should be closed with close().
*
* Note:
* On Windows Vista Glib::file_open_tmp fails with the current version of glibmm
* A special case is implemented for WIN32. This can be removed if the issue is fixed
* in future versions of glibmm
* */
{
#ifndef WIN32
#else
/* Special case for WIN32 due to a bug in glibmm
* (only needed for Windows Vista, but since there is only one windows build all builds get the workaround)
* The workaround can be removed if the bug is fixed in glibmm
*
* The code is mostly identical to the implementation in glibmm
* */
if(error)
return fileno;
#endif
}
{
bool exists = false;
if ( utf8name ) {
/* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable.
If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to
use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false)
to beginning of this function. */
// Looks like g_get_home_dir isn't safe.
//g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!");
} else {
}
if ( filename ) {
} else {
g_warning( "Unable to convert filename in IO:file_test" );
}
}
return exists;
}
/** Wrapper around g_dir_open, but taking a utf8name as first argument. */
GDir *
{
if (opsys_name) {
return ret;
} else {
return NULL;
}
}
/**
* Like g_dir_read_name, but returns a utf8name (which must be freed, unlike g_dir_read_name).
*
* N.B. Skips over any dir entries that fail to convert to utf8.
*/
gchar *
{
for (;;) {
if (!opsys_name) {
return NULL;
}
if (utf8_name) {
return utf8_name;
}
}
}
{
if ( opsysstring ) {
if ( newFileName ) {
g_warning( "input filename did not yield UTF-8" );
g_free( newFileName );
} else {
}
newFileName = 0;
// This *might* be a case that we want
// g_warning( "input failed filename->utf8, fell back to original" );
// TODO handle cases when len >= 0
} else {
}
}
return result;
}
{
if ( str ) {
} else {
while ( *ptr )
{
if ( *ptr == '\\' )
{
} else if ( *ptr < 0x80 ) {
} else {
}
ptr++;
}
}
}
return result;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :