2005-09-20 23:26:39 +10:00
/** \file wutil.h
Prototypes for wide character equivalents of various standard unix
2011-12-26 19:18:46 -08:00
functions .
2005-09-20 23:26:39 +10:00
*/
2005-10-05 01:11:39 +10:00
# ifndef FISH_WUTIL_H
# define FISH_WUTIL_H
2005-09-20 23:26:39 +10:00
2006-02-06 23:45:32 +10:00
# include <stdlib.h>
# include <stdio.h>
2005-10-05 01:11:39 +10:00
# include <wchar.h>
2005-09-20 23:26:39 +10:00
# include <dirent.h>
# include <unistd.h>
2005-10-05 01:11:39 +10:00
# include <sys/stat.h>
2005-10-06 08:37:08 +10:00
# include <sys/types.h>
2006-01-26 19:57:06 +10:00
# include <stdarg.h>
2011-12-26 19:18:46 -08:00
# include <string>
2012-02-17 15:55:54 -08:00
# include "common.h"
2011-12-26 19:18:46 -08:00
2005-09-20 23:26:39 +10:00
2006-06-17 23:07:08 +10:00
/**
Wide version of the dirent data structure
*/
2006-02-09 00:58:47 +10:00
struct wdirent
{
2006-06-17 23:07:08 +10:00
/**
The name of the current directory
*/
2006-02-09 00:58:47 +10:00
wchar_t * d_name ;
2011-12-26 19:18:46 -08:00
} ;
2006-02-09 00:58:47 +10:00
2005-11-03 01:41:59 +10:00
/**
Call this function on startup to create internal wutil
resources . This function doesn ' t do anything .
*/
void wutil_init ( ) ;
2005-09-20 23:26:39 +10:00
/**
Call this function on exit to free internal wutil resources
*/
void wutil_destroy ( ) ;
/**
Wide character version of fopen ( ) .
*/
2012-02-18 22:41:22 +05:30
FILE * wfopen ( const wcstring & path , const char * mode ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of freopen ( ) .
*/
2012-02-18 22:41:22 +05:30
FILE * wfreopen ( const wcstring & path , const char * mode , FILE * stream ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of open ( ) .
*/
2012-02-18 22:41:22 +05:30
int wopen ( const wcstring & pathname , int flags , . . . ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of creat ( ) .
*/
2012-02-18 22:41:22 +05:30
int wcreat ( const wcstring & pathname , mode_t mode ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of opendir ( ) .
*/
2012-02-18 22:41:22 +05:30
DIR * wopendir ( const wcstring & name ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of stat ( ) .
*/
2012-02-18 22:41:22 +05:30
int wstat ( const wcstring & file_name , struct stat * buf ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of lstat ( ) .
*/
2012-02-18 22:41:22 +05:30
int lwstat ( const wcstring & file_name , struct stat * buf ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of access ( ) .
*/
2012-02-18 22:41:22 +05:30
int waccess ( const wcstring & pathname , int mode ) ;
2005-09-20 23:26:39 +10:00
2012-02-16 00:24:27 -08:00
/**
Wide character version of unlink ( ) .
*/
2012-02-18 22:41:22 +05:30
int wunlink ( const wcstring & pathname ) ;
2012-02-16 00:24:27 -08:00
2005-09-20 23:26:39 +10:00
/**
Wide character version of perror ( ) .
*/
2012-02-18 22:41:22 +05:30
void wperror ( const wcstring & s ) ;
2005-09-20 23:26:39 +10:00
/**
Wide character version of getcwd ( ) .
*/
wchar_t * wgetcwd ( wchar_t * buff , size_t sz ) ;
/**
Wide character version of chdir ( )
*/
2012-02-18 22:41:22 +05:30
int wchdir ( const wcstring & dir ) ;
2005-09-20 23:26:39 +10:00
2011-12-26 19:18:46 -08:00
/**
2006-02-03 01:33:30 +10:00
Wide character version of realpath function . Just like the GNU
2006-02-03 01:23:56 +10:00
version of realpath , wrealpath will accept 0 as the value for the
second argument , in which case the result will be allocated using
malloc , and must be free ' d by the user .
*/
2012-02-18 22:41:22 +05:30
wchar_t * wrealpath ( const wcstring & pathname , wchar_t * resolved_path ) ;
2006-02-03 01:23:56 +10:00
2006-06-17 23:07:08 +10:00
/**
Wide character version of readdir ( )
*/
2012-02-17 18:08:08 -08:00
bool wreaddir ( DIR * dir , std : : wstring & outPath , bool * outIsDirectory = NULL ) ;
2006-02-09 00:58:47 +10:00
2006-06-14 23:22:40 +10:00
/**
Wide character version of dirname ( )
*/
2011-12-26 19:18:46 -08:00
std : : wstring wdirname ( const std : : wstring & path ) ;
2006-06-14 23:22:40 +10:00
/**
Wide character version of basename ( )
*/
2011-12-26 19:18:46 -08:00
std : : wstring wbasename ( const std : : wstring & path ) ;
2006-06-14 23:22:40 +10:00
2006-07-20 08:55:49 +10:00
/**
Wide character wrapper around the gettext function . For historic
reasons , unlike the real gettext function , wgettext takes care of
setting the correct domain , etc . using the textdomain and
bindtextdomain functions . This should probably be moved out of
wgettext , so that wgettext will be nothing more than a wrapper
around gettext , like all other functions in this file .
*/
const wchar_t * wgettext ( const wchar_t * in ) ;
2012-02-17 15:55:54 -08:00
wcstring wgettext2 ( const wcstring & in ) ;
2006-06-14 23:22:40 +10:00
2006-08-12 00:55:28 +10:00
/**
Wide character version of getenv
*/
2012-02-18 22:41:22 +05:30
const wchar_t * wgetenv ( const wcstring & name ) ;
2006-08-12 00:55:28 +10:00
2006-09-09 00:11:28 +10:00
/**
Wide character version of mkdir
*/
2012-02-18 22:41:22 +05:30
int wmkdir ( const wcstring & dir , int mode ) ;
2006-08-12 00:55:28 +10:00
2006-10-21 08:33:47 +10:00
/**
Wide character version of rename
*/
2012-02-18 22:41:22 +05:30
int wrename ( const wcstring & oldName , const wcstring & newName ) ;
2006-10-21 08:33:47 +10:00
2005-09-20 23:26:39 +10:00
# endif