Re: Writing portable code



Hey,

I think you might be coming at this from the wrong direction. This is
how I've generally seen people do OS specific stuff. I've only ever
bothered with directory separators and file roots before, but I'm pretty
sure these would work. Probably not the prettiest solution, and I really
didn't bother to check if Glib had some kind of API to this.

#ifdef WIN32
directory_separator = "\\"
username            = GetUserName // should work, win32 api
data_directory      = "C:\\" << username << "\\whatev"
GlobalMemoryStatus() // win32
#else 
directory_separator = "/"
username            = getlogin() or cuserid() // unistd.h, stdio.h
sysinfo // for memory size, sys/sysinfo.h
#endif

Pseudo-code obviously, but you get the idea. Should get you up and
running anyway.

Lyle

On Sat, 2010-01-16 at 02:51 -0300, Esdras Beleza wrote:
> Hi folks,
> 
> 
> 
> 
> Please, I'd like to know some tips to write portable gtkmm code that
> would compile and run in Linux, Windows, MacOS etc. 
> 
> 
> My first question is: what is an easy way to determine the user
> configuration directory, like ~/.config or C:\Documents and Settings
> \Username\Application Data\? Does Gtkmm, Glib or anything have any
> support to determine this kind of information, like system details,
> directory separator, etc.?
> 
> 
> 
> 
> Thanks,
> 
> 
> 
> 
> Esdras
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]