Search
lxdream.org :: lxdream :: r1041:5fcc39857c5c
lxdream 0.9.1
released Jun 29
Download Now
changeset1041:5fcc39857c5c
parent1040:9e3e41eab2db
child1042:0fd066956482
authornkeynes
dateFri Jun 26 05:47:04 2009 +0000 (10 years ago)
Refactor path operations into lxpaths.[ch]
src/Makefile.am
src/Makefile.in
src/cocoaui/cocoa_ctrl.m
src/cocoaui/cocoa_path.m
src/cocoaui/cocoaui.m
src/cocoaui/paths_osx.m
src/config.c
src/config.h
src/dream.h
src/dreamcast.c
src/gtkui/gtk_path.c
src/gtkui/gtkcb.c
src/gui.h
src/guiutil.c
src/lxdream.h
src/lxpaths.c
src/lxpaths.h
src/main.c
src/plugin.c
1.1 --- a/src/Makefile.am Thu Jun 25 21:21:18 2009 +0000
1.2 +++ b/src/Makefile.am Fri Jun 26 05:47:04 2009 +0000
1.3 @@ -44,7 +44,7 @@
1.4 gettext.h mem.c mem.h sdram.c mmio.h watch.c \
1.5 asic.c asic.h clock.h serial.h \
1.6 syscall.c syscall.h bios.c dcload.c gdbserver.c \
1.7 - netutil.c netutil.h guiutil.c \
1.8 + netutil.c netutil.h lxpaths.c lxpaths.h \
1.9 gdrom/ide.c gdrom/ide.h gdrom/packet.h gdrom/gdimage.c \
1.10 gdrom/gdrom.c gdrom/gdrom.h gdrom/nrg.c gdrom/cdi.c gdrom/gdi.c \
1.11 gdrom/edc_ecc.c gdrom/ecc.h gdrom/edc_crctable.h gdrom/edc_encoder.h \
2.1 --- a/src/Makefile.in Thu Jun 25 21:21:18 2009 +0000
2.2 +++ b/src/Makefile.in Fri Jun 26 05:47:04 2009 +0000
2.3 @@ -142,23 +142,23 @@
2.4 lxdream.h dream.h gui.h cpu.h hook.h gettext.h mem.c mem.h \
2.5 sdram.c mmio.h watch.c asic.c asic.h clock.h serial.h \
2.6 syscall.c syscall.h bios.c dcload.c gdbserver.c netutil.c \
2.7 - netutil.h guiutil.c gdrom/ide.c gdrom/ide.h gdrom/packet.h \
2.8 - gdrom/gdimage.c gdrom/gdrom.c gdrom/gdrom.h gdrom/nrg.c \
2.9 - gdrom/cdi.c gdrom/gdi.c gdrom/edc_ecc.c gdrom/ecc.h \
2.10 - gdrom/edc_crctable.h gdrom/edc_encoder.h gdrom/edc_l2sq.h \
2.11 - gdrom/edc_scramble.h gdrom/gddriver.h dreamcast.c dreamcast.h \
2.12 - eventq.c eventq.h sh4/sh4.c sh4/intc.c sh4/intc.h sh4/sh4mem.c \
2.13 - sh4/timer.c sh4/dmac.c sh4/mmu.c sh4/sh4core.c sh4/sh4core.h \
2.14 - sh4/sh4dasm.c sh4/sh4dasm.h sh4/sh4mmio.c sh4/sh4mmio.h \
2.15 - sh4/scif.c sh4/sh4stat.c sh4/sh4stat.h xlat/xltcache.c \
2.16 - xlat/xltcache.h sh4/sh4.h sh4/dmac.h sh4/pmm.c sh4/cache.c \
2.17 - sh4/mmu.h aica/armcore.c aica/armcore.h aica/armdasm.c \
2.18 - aica/armdasm.h aica/armmem.c aica/aica.c aica/aica.h \
2.19 - aica/audio.c aica/audio.h pvr2/pvr2.c pvr2/pvr2.h \
2.20 - pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c \
2.21 - pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c \
2.22 - pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c \
2.23 - pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
2.24 + netutil.h lxpaths.c lxpaths.h gdrom/ide.c gdrom/ide.h \
2.25 + gdrom/packet.h gdrom/gdimage.c gdrom/gdrom.c gdrom/gdrom.h \
2.26 + gdrom/nrg.c gdrom/cdi.c gdrom/gdi.c gdrom/edc_ecc.c \
2.27 + gdrom/ecc.h gdrom/edc_crctable.h gdrom/edc_encoder.h \
2.28 + gdrom/edc_l2sq.h gdrom/edc_scramble.h gdrom/gddriver.h \
2.29 + dreamcast.c dreamcast.h eventq.c eventq.h sh4/sh4.c sh4/intc.c \
2.30 + sh4/intc.h sh4/sh4mem.c sh4/timer.c sh4/dmac.c sh4/mmu.c \
2.31 + sh4/sh4core.c sh4/sh4core.h sh4/sh4dasm.c sh4/sh4dasm.h \
2.32 + sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c sh4/sh4stat.c \
2.33 + sh4/sh4stat.h xlat/xltcache.c xlat/xltcache.h sh4/sh4.h \
2.34 + sh4/dmac.h sh4/pmm.c sh4/cache.c sh4/mmu.h aica/armcore.c \
2.35 + aica/armcore.h aica/armdasm.c aica/armdasm.h aica/armmem.c \
2.36 + aica/aica.c aica/aica.h aica/audio.c aica/audio.h pvr2/pvr2.c \
2.37 + pvr2/pvr2.h pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c \
2.38 + pvr2/rendsort.c pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c \
2.39 + pvr2/scene.c pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c \
2.40 + pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
2.41 pvr2/fragment.glsl maple/maple.c maple/maple.h \
2.42 maple/controller.c maple/kbd.c maple/mouse.c maple/lightgun.c \
2.43 maple/vmu.c loader.c loader.h elf.h bootstrap.c bootstrap.h \
2.44 @@ -238,7 +238,7 @@
2.45 lxdream-asic.$(OBJEXT) lxdream-syscall.$(OBJEXT) \
2.46 lxdream-bios.$(OBJEXT) lxdream-dcload.$(OBJEXT) \
2.47 lxdream-gdbserver.$(OBJEXT) lxdream-netutil.$(OBJEXT) \
2.48 - lxdream-guiutil.$(OBJEXT) lxdream-ide.$(OBJEXT) \
2.49 + lxdream-lxpaths.$(OBJEXT) lxdream-ide.$(OBJEXT) \
2.50 lxdream-gdimage.$(OBJEXT) lxdream-gdrom.$(OBJEXT) \
2.51 lxdream-nrg.$(OBJEXT) lxdream-cdi.$(OBJEXT) \
2.52 lxdream-gdi.$(OBJEXT) lxdream-edc_ecc.$(OBJEXT) \
2.53 @@ -542,38 +542,39 @@
2.54 lxdream_SOURCES = main.c version.c config.c config.h lxdream.h dream.h \
2.55 gui.h cpu.h hook.h gettext.h mem.c mem.h sdram.c mmio.h \
2.56 watch.c asic.c asic.h clock.h serial.h syscall.c syscall.h \
2.57 - bios.c dcload.c gdbserver.c netutil.c netutil.h guiutil.c \
2.58 - gdrom/ide.c gdrom/ide.h gdrom/packet.h gdrom/gdimage.c \
2.59 - gdrom/gdrom.c gdrom/gdrom.h gdrom/nrg.c gdrom/cdi.c \
2.60 - gdrom/gdi.c gdrom/edc_ecc.c gdrom/ecc.h gdrom/edc_crctable.h \
2.61 - gdrom/edc_encoder.h gdrom/edc_l2sq.h gdrom/edc_scramble.h \
2.62 - gdrom/gddriver.h dreamcast.c dreamcast.h eventq.c eventq.h \
2.63 - sh4/sh4.c sh4/intc.c sh4/intc.h sh4/sh4mem.c sh4/timer.c \
2.64 - sh4/dmac.c sh4/mmu.c sh4/sh4core.c sh4/sh4core.h sh4/sh4dasm.c \
2.65 - sh4/sh4dasm.h sh4/sh4mmio.c sh4/sh4mmio.h sh4/scif.c \
2.66 - sh4/sh4stat.c sh4/sh4stat.h xlat/xltcache.c xlat/xltcache.h \
2.67 - sh4/sh4.h sh4/dmac.h sh4/pmm.c sh4/cache.c sh4/mmu.h \
2.68 - aica/armcore.c aica/armcore.h aica/armdasm.c aica/armdasm.h \
2.69 - aica/armmem.c aica/aica.c aica/aica.h aica/audio.c \
2.70 - aica/audio.h pvr2/pvr2.c pvr2/pvr2.h pvr2/pvr2mem.c \
2.71 - pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c pvr2/texcache.c \
2.72 - pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c pvr2/scene.h \
2.73 - pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c pvr2/glutil.h \
2.74 - pvr2/glrender.c pvr2/vertex.glsl pvr2/fragment.glsl \
2.75 - maple/maple.c maple/maple.h maple/controller.c maple/kbd.c \
2.76 - maple/mouse.c maple/lightgun.c maple/vmu.c loader.c loader.h \
2.77 - elf.h bootstrap.c bootstrap.h util.c gdlist.c gdlist.h \
2.78 - vmu/vmuvol.c vmu/vmuvol.h vmu/vmulist.c vmu/vmulist.h \
2.79 - display.c display.h dckeysyms.h drivers/audio_null.c \
2.80 - drivers/video_null.c drivers/cd_mmc.c drivers/video_gl.c \
2.81 - drivers/video_gl.h drivers/gl_fbo.c sh4/sh4.def sh4/sh4core.in \
2.82 - sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in hotkeys.c \
2.83 - hotkeys.h $(am__append_1) $(am__append_2) $(am__append_4) \
2.84 - $(am__append_5) $(am__append_6) $(am__append_7) \
2.85 - $(am__append_8) $(am__append_9) $(am__append_10) \
2.86 - $(am__append_17) $(am__append_19) $(am__append_21) \
2.87 - $(am__append_23) $(am__append_25) $(am__append_27) \
2.88 - $(am__append_28) $(am__append_29) $(am__append_30)
2.89 + bios.c dcload.c gdbserver.c netutil.c netutil.h lxpaths.c \
2.90 + lxpaths.h gdrom/ide.c gdrom/ide.h gdrom/packet.h \
2.91 + gdrom/gdimage.c gdrom/gdrom.c gdrom/gdrom.h gdrom/nrg.c \
2.92 + gdrom/cdi.c gdrom/gdi.c gdrom/edc_ecc.c gdrom/ecc.h \
2.93 + gdrom/edc_crctable.h gdrom/edc_encoder.h gdrom/edc_l2sq.h \
2.94 + gdrom/edc_scramble.h gdrom/gddriver.h dreamcast.c dreamcast.h \
2.95 + eventq.c eventq.h sh4/sh4.c sh4/intc.c sh4/intc.h sh4/sh4mem.c \
2.96 + sh4/timer.c sh4/dmac.c sh4/mmu.c sh4/sh4core.c sh4/sh4core.h \
2.97 + sh4/sh4dasm.c sh4/sh4dasm.h sh4/sh4mmio.c sh4/sh4mmio.h \
2.98 + sh4/scif.c sh4/sh4stat.c sh4/sh4stat.h xlat/xltcache.c \
2.99 + xlat/xltcache.h sh4/sh4.h sh4/dmac.h sh4/pmm.c sh4/cache.c \
2.100 + sh4/mmu.h aica/armcore.c aica/armcore.h aica/armdasm.c \
2.101 + aica/armdasm.h aica/armmem.c aica/aica.c aica/aica.h \
2.102 + aica/audio.c aica/audio.h pvr2/pvr2.c pvr2/pvr2.h \
2.103 + pvr2/pvr2mem.c pvr2/pvr2mmio.h pvr2/tacore.c pvr2/rendsort.c \
2.104 + pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c \
2.105 + pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c \
2.106 + pvr2/glutil.h pvr2/glrender.c pvr2/vertex.glsl \
2.107 + pvr2/fragment.glsl maple/maple.c maple/maple.h \
2.108 + maple/controller.c maple/kbd.c maple/mouse.c maple/lightgun.c \
2.109 + maple/vmu.c loader.c loader.h elf.h bootstrap.c bootstrap.h \
2.110 + util.c gdlist.c gdlist.h vmu/vmuvol.c vmu/vmuvol.h \
2.111 + vmu/vmulist.c vmu/vmulist.h display.c display.h dckeysyms.h \
2.112 + drivers/audio_null.c drivers/video_null.c drivers/cd_mmc.c \
2.113 + drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c \
2.114 + sh4/sh4.def sh4/sh4core.in sh4/sh4x86.in sh4/sh4dasm.in \
2.115 + sh4/sh4stat.in hotkeys.c hotkeys.h $(am__append_1) \
2.116 + $(am__append_2) $(am__append_4) $(am__append_5) \
2.117 + $(am__append_6) $(am__append_7) $(am__append_8) \
2.118 + $(am__append_9) $(am__append_10) $(am__append_17) \
2.119 + $(am__append_19) $(am__append_21) $(am__append_23) \
2.120 + $(am__append_25) $(am__append_27) $(am__append_28) \
2.121 + $(am__append_29) $(am__append_30)
2.122 lxdream_CPPFLAGS = @LXDREAMCPPFLAGS@
2.123 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@
2.124 @BUILD_SH4X86_TRUE@test_testsh4x86_CPPFLAGS = @LXDREAMCPPFLAGS@
2.125 @@ -793,7 +794,6 @@
2.126 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-gtk_win.Po@am__quote@
2.127 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-gtkcb.Po@am__quote@
2.128 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-gtkui.Po@am__quote@
2.129 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-guiutil.Po@am__quote@
2.130 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-hotkeys.Po@am__quote@
2.131 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-i386-dis.Po@am__quote@
2.132 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-ide.Po@am__quote@
2.133 @@ -803,6 +803,7 @@
2.134 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-kbd.Po@am__quote@
2.135 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-lightgun.Po@am__quote@
2.136 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-loader.Po@am__quote@
2.137 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-lxpaths.Po@am__quote@
2.138 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-main.Po@am__quote@
2.139 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-maple.Po@am__quote@
2.140 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-mem.Po@am__quote@
2.141 @@ -1104,19 +1105,19 @@
2.142 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.143 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-netutil.obj `if test -f 'netutil.c'; then $(CYGPATH_W) 'netutil.c'; else $(CYGPATH_W) '$(srcdir)/netutil.c'; fi`
2.144
2.145 -lxdream-guiutil.o: guiutil.c
2.146 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-guiutil.o -MD -MP -MF "$(DEPDIR)/lxdream-guiutil.Tpo" -c -o lxdream-guiutil.o `test -f 'guiutil.c' || echo '$(srcdir)/'`guiutil.c; \
2.147 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-guiutil.Tpo" "$(DEPDIR)/lxdream-guiutil.Po"; else rm -f "$(DEPDIR)/lxdream-guiutil.Tpo"; exit 1; fi
2.148 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='guiutil.c' object='lxdream-guiutil.o' libtool=no @AMDEPBACKSLASH@
2.149 +lxdream-lxpaths.o: lxpaths.c
2.150 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-lxpaths.o -MD -MP -MF "$(DEPDIR)/lxdream-lxpaths.Tpo" -c -o lxdream-lxpaths.o `test -f 'lxpaths.c' || echo '$(srcdir)/'`lxpaths.c; \
2.151 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-lxpaths.Tpo" "$(DEPDIR)/lxdream-lxpaths.Po"; else rm -f "$(DEPDIR)/lxdream-lxpaths.Tpo"; exit 1; fi
2.152 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lxpaths.c' object='lxdream-lxpaths.o' libtool=no @AMDEPBACKSLASH@
2.153 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.154 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-guiutil.o `test -f 'guiutil.c' || echo '$(srcdir)/'`guiutil.c
2.155 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-lxpaths.o `test -f 'lxpaths.c' || echo '$(srcdir)/'`lxpaths.c
2.156
2.157 -lxdream-guiutil.obj: guiutil.c
2.158 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-guiutil.obj -MD -MP -MF "$(DEPDIR)/lxdream-guiutil.Tpo" -c -o lxdream-guiutil.obj `if test -f 'guiutil.c'; then $(CYGPATH_W) 'guiutil.c'; else $(CYGPATH_W) '$(srcdir)/guiutil.c'; fi`; \
2.159 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-guiutil.Tpo" "$(DEPDIR)/lxdream-guiutil.Po"; else rm -f "$(DEPDIR)/lxdream-guiutil.Tpo"; exit 1; fi
2.160 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='guiutil.c' object='lxdream-guiutil.obj' libtool=no @AMDEPBACKSLASH@
2.161 +lxdream-lxpaths.obj: lxpaths.c
2.162 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-lxpaths.obj -MD -MP -MF "$(DEPDIR)/lxdream-lxpaths.Tpo" -c -o lxdream-lxpaths.obj `if test -f 'lxpaths.c'; then $(CYGPATH_W) 'lxpaths.c'; else $(CYGPATH_W) '$(srcdir)/lxpaths.c'; fi`; \
2.163 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-lxpaths.Tpo" "$(DEPDIR)/lxdream-lxpaths.Po"; else rm -f "$(DEPDIR)/lxdream-lxpaths.Tpo"; exit 1; fi
2.164 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='lxpaths.c' object='lxdream-lxpaths.obj' libtool=no @AMDEPBACKSLASH@
2.165 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.166 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-guiutil.obj `if test -f 'guiutil.c'; then $(CYGPATH_W) 'guiutil.c'; else $(CYGPATH_W) '$(srcdir)/guiutil.c'; fi`
2.167 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-lxpaths.obj `if test -f 'lxpaths.c'; then $(CYGPATH_W) 'lxpaths.c'; else $(CYGPATH_W) '$(srcdir)/lxpaths.c'; fi`
2.168
2.169 lxdream-ide.o: gdrom/ide.c
2.170 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-ide.o -MD -MP -MF "$(DEPDIR)/lxdream-ide.Tpo" -c -o lxdream-ide.o `test -f 'gdrom/ide.c' || echo '$(srcdir)/'`gdrom/ide.c; \
3.1 --- a/src/cocoaui/cocoa_ctrl.m Thu Jun 25 21:21:18 2009 +0000
3.2 +++ b/src/cocoaui/cocoa_ctrl.m Fri Jun 26 05:47:04 2009 +0000
3.3 @@ -18,6 +18,7 @@
3.4
3.5 #include "cocoaui.h"
3.6 #include "config.h"
3.7 +#include "lxpaths.h"
3.8 #include "display.h"
3.9 #include "maple/maple.h"
3.10 #include "vmu/vmulist.h"
3.11 @@ -596,14 +597,14 @@
3.12 NSOpenPanel *panel = [NSOpenPanel openPanel];
3.13 VMULoadValidator *valid = [[VMULoadValidator alloc] autorelease];
3.14 [panel setDelegate: valid];
3.15 - NSInteger result = [panel runModalForDirectory: [NSString stringWithUTF8String: gui_get_configurable_path(CONFIG_VMU_PATH)]
3.16 + NSInteger result = [panel runModalForDirectory: [NSString stringWithUTF8String: get_gui_path(CONFIG_VMU_PATH)]
3.17 file: nil types: array];
3.18 if( result == NSOKButton ) {
3.19 vmu_filename = [[panel filename] UTF8String];
3.20 int idx = vmulist_get_index_by_filename(vmu_filename);
3.21 [sender selectItemWithTag: (FIRST_VMU_TAG+idx)];
3.22 new_device_class = &vmu_class;
3.23 - gui_set_configurable_path(CONFIG_VMU_PATH, [[panel directory] UTF8String]);
3.24 + set_gui_path(CONFIG_VMU_PATH, [[panel directory] UTF8String]);
3.25 } else {
3.26 /* Cancelled - restore previous value */
3.27 setDevicePopupSelection( sender, current );
3.28 @@ -616,7 +617,7 @@
3.29 [panel setRequiredFileType: @"vmu"];
3.30 VMUCreateValidator *valid = [[VMUCreateValidator alloc] autorelease];
3.31 [panel setDelegate: valid];
3.32 - NSInteger result = [panel runModalForDirectory: [NSString stringWithUTF8String: gui_get_configurable_path(CONFIG_VMU_PATH)]
3.33 + NSInteger result = [panel runModalForDirectory: [NSString stringWithUTF8String: get_gui_path(CONFIG_VMU_PATH)]
3.34 file: nil];
3.35 if( result == NSFileHandlingPanelOKButton ) {
3.36 /* Validator has already created the file by now */
3.37 @@ -624,7 +625,7 @@
3.38 int idx = vmulist_get_index_by_filename(vmu_filename);
3.39 [sender selectItemWithTag: (FIRST_VMU_TAG+idx)];
3.40 new_device_class = &vmu_class;
3.41 - gui_set_configurable_path(CONFIG_VMU_PATH, [[panel directory] UTF8String]);
3.42 + set_gui_path(CONFIG_VMU_PATH, [[panel directory] UTF8String]);
3.43 } else {
3.44 setDevicePopupSelection( sender, current );
3.45 return;
4.1 --- a/src/cocoaui/cocoa_path.m Thu Jun 25 21:21:18 2009 +0000
4.2 +++ b/src/cocoaui/cocoa_path.m Fri Jun 26 05:47:04 2009 +0000
4.3 @@ -18,6 +18,7 @@
4.4
4.5 #include "cocoaui.h"
4.6 #include "config.h"
4.7 +#include "lxpaths.h"
4.8 #include "dreamcast.h"
4.9
4.10 @interface LxdreamPrefsPathPane: LxdreamPrefsPane
5.1 --- a/src/cocoaui/cocoaui.m Thu Jun 25 21:21:18 2009 +0000
5.2 +++ b/src/cocoaui/cocoaui.m Fri Jun 26 05:47:04 2009 +0000
5.3 @@ -25,6 +25,7 @@
5.4 #include "dream.h"
5.5 #include "dreamcast.h"
5.6 #include "config.h"
5.7 +#include "lxpaths.h"
5.8 #include "display.h"
5.9 #include "gui.h"
5.10 #include "gdrom/gdrom.h"
5.11 @@ -240,47 +241,47 @@
5.12 - (void) load_action: (id)sender
5.13 {
5.14 NSOpenPanel *panel = [NSOpenPanel openPanel];
5.15 - NSString *path = [NSString stringWithCString: gui_get_configurable_path(CONFIG_SAVE_PATH)];
5.16 + NSString *path = [NSString stringWithCString: get_gui_path(CONFIG_SAVE_PATH)];
5.17 NSArray *fileTypes = [NSArray arrayWithObject: @"dst"];
5.18 int result = [panel runModalForDirectory: path file: nil types: fileTypes];
5.19 if( result == NSOKButton && [[panel filenames] count] > 0 ) {
5.20 NSString *filename = [[panel filenames] objectAtIndex: 0];
5.21 dreamcast_load_state( [filename UTF8String] );
5.22 - gui_set_configurable_path(CONFIG_SAVE_PATH, [[panel directory] UTF8String]);
5.23 + set_gui_path(CONFIG_SAVE_PATH, [[panel directory] UTF8String]);
5.24 }
5.25 }
5.26 - (void) save_action: (id)sender
5.27 {
5.28 NSSavePanel *panel = [NSSavePanel savePanel];
5.29 - NSString *path = [NSString stringWithCString: gui_get_configurable_path(CONFIG_SAVE_PATH)];
5.30 + NSString *path = [NSString stringWithCString: get_gui_path(CONFIG_SAVE_PATH)];
5.31 [panel setRequiredFileType: @"dst"];
5.32 int result = [panel runModalForDirectory: path file:@""];
5.33 if( result == NSOKButton ) {
5.34 NSString *filename = [panel filename];
5.35 dreamcast_save_state( [filename UTF8String] );
5.36 - gui_set_configurable_path(CONFIG_SAVE_PATH, [[panel directory] UTF8String]);
5.37 + set_gui_path(CONFIG_SAVE_PATH, [[panel directory] UTF8String]);
5.38 }
5.39 }
5.40 - (void) load_binary_action: (id)sender
5.41 {
5.42 NSOpenPanel *panel = [NSOpenPanel openPanel];
5.43 - NSString *path = [NSString stringWithCString: gui_get_configurable_path(CONFIG_DEFAULT_PATH)];
5.44 + NSString *path = [NSString stringWithCString: get_gui_path(CONFIG_DEFAULT_PATH)];
5.45 int result = [panel runModalForDirectory: path file: nil types: nil];
5.46 if( result == NSOKButton && [[panel filenames] count] > 0 ) {
5.47 NSString *filename = [[panel filenames] objectAtIndex: 0];
5.48 file_load_magic( [filename UTF8String] );
5.49 - gui_set_configurable_path(CONFIG_DEFAULT_PATH, [[panel directory] UTF8String]);
5.50 + set_gui_path(CONFIG_DEFAULT_PATH, [[panel directory] UTF8String]);
5.51 }
5.52 }
5.53 - (void) mount_action: (id)sender
5.54 {
5.55 NSOpenPanel *panel = [NSOpenPanel openPanel];
5.56 - NSString *path = [NSString stringWithCString: gui_get_configurable_path(CONFIG_DEFAULT_PATH)];
5.57 + NSString *path = [NSString stringWithCString: get_gui_path(CONFIG_DEFAULT_PATH)];
5.58 int result = [panel runModalForDirectory: path file: nil types: nil];
5.59 if( result == NSOKButton && [[panel filenames] count] > 0 ) {
5.60 NSString *filename = [[panel filenames] objectAtIndex: 0];
5.61 gdrom_mount_image( [filename UTF8String] );
5.62 - gui_set_configurable_path(CONFIG_DEFAULT_PATH, [[panel directory] UTF8String]);
5.63 + set_gui_path(CONFIG_DEFAULT_PATH, [[panel directory] UTF8String]);
5.64 }
5.65 }
5.66 - (void) pause_action: (id)sender
6.1 --- a/src/cocoaui/paths_osx.m Thu Jun 25 21:21:18 2009 +0000
6.2 +++ b/src/cocoaui/paths_osx.m Fri Jun 26 05:47:04 2009 +0000
6.3 @@ -19,8 +19,10 @@
6.4 */
6.5
6.6 #include <string.h>
6.7 +#include <glib/gstrfuncs.h>
6.8
6.9 #include "lxdream.h"
6.10 +#include "lxpaths.h"
6.11
6.12 #include <AppKit/AppKit.h>
6.13
7.1 --- a/src/config.c Thu Jun 25 21:21:18 2009 +0000
7.2 +++ b/src/config.c Fri Jun 26 05:47:04 2009 +0000
7.3 @@ -18,17 +18,16 @@
7.4
7.5 #include <unistd.h>
7.6 #include <stdio.h>
7.7 -#include <ctype.h>
7.8 #include <errno.h>
7.9 #include <stdlib.h>
7.10 #include <string.h>
7.11 -#include <wordexp.h>
7.12 #include <glib/gmem.h>
7.13 #include <glib/gstrfuncs.h>
7.14 #include <sys/types.h>
7.15 #include <sys/stat.h>
7.16 #include "dream.h"
7.17 #include "config.h"
7.18 +#include "lxpaths.h"
7.19 #include "maple/maple.h"
7.20
7.21 #define MAX_ROOT_GROUPS 16
7.22 @@ -196,82 +195,6 @@
7.23 }
7.24 }
7.25
7.26 -gchar *get_expanded_path( const gchar *input )
7.27 -{
7.28 - wordexp_t we;
7.29 - if( input == NULL ) {
7.30 - return NULL;
7.31 - }
7.32 - memset(&we,0,sizeof(we));
7.33 - int result = wordexp(input, &we, WRDE_NOCMD);
7.34 - if( result != 0 || we.we_wordc == 0 ) {
7.35 - /* On failure, return the original input unchanged */
7.36 - return g_strdup(input);
7.37 - } else {
7.38 - /* On success, concatenate all 'words' together into a single
7.39 - * space-separated string
7.40 - */
7.41 - int length = we.we_wordc, i;
7.42 - gchar *result, *p;
7.43 -
7.44 - for( i=0; i<we.we_wordc; i++ ) {
7.45 - length += strlen(we.we_wordv[i]);
7.46 - }
7.47 - p = result = g_malloc(length);
7.48 - for( i=0; i<we.we_wordc; i++ ) {
7.49 - if( i != 0 )
7.50 - *p++ = ' ';
7.51 - strcpy( p, we.we_wordv[i] );
7.52 - p += strlen(p);
7.53 - }
7.54 - wordfree(&we);
7.55 - return result;
7.56 - }
7.57 -}
7.58 -
7.59 -/**
7.60 - * Test if we need to escape a path to prevent substitution mangling.
7.61 - * @return TRUE if the input value contains any character that doesn't
7.62 - * match [a-zA-Z0-9._@%/] (this will escape slightly more than it needs to,
7.63 - * but is safe)
7.64 - */
7.65 -gboolean path_needs_escaping( const gchar *value )
7.66 -{
7.67 - const gchar *p = value;
7.68 - while( *p ) {
7.69 - if( !isalnum(*p) && *p != '.' && *p != '_' &&
7.70 - *p != '@' && *p != '%' && *p != '/' ) {
7.71 - return TRUE;
7.72 - }
7.73 - p++;
7.74 - }
7.75 - return FALSE;
7.76 -}
7.77 -
7.78 -gchar *get_escaped_path( const gchar *value )
7.79 -{
7.80 - if( value != NULL && path_needs_escaping(value) ) {
7.81 - /* Escape with "", and backslash the remaining characters:
7.82 - * \ " $ `
7.83 - */
7.84 - char buf[strlen(value)*2+3];
7.85 - const char *s = value;
7.86 - char *p = buf;
7.87 - *p++ = '\"';
7.88 - while( *s ) {
7.89 - if( *s == '\\' || *s == '"' || *s == '$' || *s == '`' ) {
7.90 - *p++ = '\\';
7.91 - }
7.92 - *p++ = *s++;
7.93 - }
7.94 - *p++ = '\"';
7.95 - *p = '\0';
7.96 - return g_strdup(buf);
7.97 - } else {
7.98 - return g_strdup(value);
7.99 - }
7.100 -}
7.101 -
7.102 gchar *lxdream_get_global_config_path_value( int key )
7.103 {
7.104 const gchar *str = lxdream_get_global_config_value(key);
8.1 --- a/src/config.h Thu Jun 25 21:21:18 2009 +0000
8.2 +++ b/src/config.h Fri Jun 26 05:47:04 2009 +0000
8.3 @@ -130,19 +130,6 @@
8.4 */
8.5 void lxdream_make_config_dir( );
8.6
8.7 -/**
8.8 - * Escape a pathname if needed to prevent shell substitution.
8.9 - * @return a newly allocated string (or NULL if the input is NULL)
8.10 - */
8.11 -gchar *get_escaped_path( const gchar *name );
8.12 -
8.13 -/**
8.14 - * Expand a pathname according to standard shell substitution rules
8.15 - * (excluding command substitutions).
8.16 - * @return a newly allocated string (or NULL if the input is NULL)
8.17 - */
8.18 -gchar *get_expanded_path( const gchar *name );
8.19 -
8.20 #ifdef __cplusplus
8.21 }
8.22 #endif
9.1 --- a/src/dream.h Thu Jun 25 21:21:18 2009 +0000
9.2 +++ b/src/dream.h Fri Jun 26 05:47:04 2009 +0000
9.3 @@ -89,7 +89,7 @@
9.4
9.5 void fwrite_string( const char *s, FILE *f );
9.6 int fread_string( char *s, int maxlen, FILE *f );
9.7 -void fwrite_gzip( void *p, size_t size, size_t num, FILE *f );
9.8 +int fwrite_gzip( void *p, size_t size, size_t num, FILE *f );
9.9 int fread_gzip( void *p, size_t size, size_t num, FILE *f );
9.10 void fwrite_dump( unsigned char *buf, unsigned int length, FILE *f );
9.11 void fwrite_dump32( unsigned int *buf, unsigned int length, FILE *f );
10.1 --- a/src/dreamcast.c Thu Jun 25 21:21:18 2009 +0000
10.2 +++ b/src/dreamcast.c Fri Jun 26 05:47:04 2009 +0000
10.3 @@ -21,6 +21,7 @@
10.4 #include <glib.h>
10.5 #include <unistd.h>
10.6 #include "lxdream.h"
10.7 +#include "lxpaths.h"
10.8 #include "dream.h"
10.9 #include "mem.h"
10.10 #include "dreamcast.h"
10.11 @@ -135,6 +136,7 @@
10.12 }
10.13 g_free(bios_path);
10.14 g_free(flash_path);
10.15 + reset_gui_paths();
10.16 }
10.17
10.18 void dreamcast_save_flash()
11.1 --- a/src/gtkui/gtk_path.c Thu Jun 25 21:21:18 2009 +0000
11.2 +++ b/src/gtkui/gtk_path.c Fri Jun 26 05:47:04 2009 +0000
11.3 @@ -23,6 +23,7 @@
11.4 #include "lxdream.h"
11.5 #include "dreamcast.h"
11.6 #include "config.h"
11.7 +#include "lxpaths.h"
11.8 #include "gtkui/gtkui.h"
11.9
11.10 static GtkWidget *path_entry[CONFIG_KEY_MAX];
11.11 @@ -119,7 +120,6 @@
11.12
11.13 lxdream_save_config();
11.14 dreamcast_config_changed();
11.15 - gui_config_paths_changed();
11.16 gtk_gui_update();
11.17 }
11.18 }
12.1 --- a/src/gtkui/gtkcb.c Thu Jun 25 21:21:18 2009 +0000
12.2 +++ b/src/gtkui/gtkcb.c Fri Jun 26 05:47:04 2009 +0000
12.3 @@ -16,8 +16,11 @@
12.4 * GNU General Public License for more details.
12.5 */
12.6
12.7 -#include "dream.h"
12.8 +#include <stdlib.h>
12.9 +
12.10 +#include "lxdream.h"
12.11 #include "config.h"
12.12 +#include "lxpaths.h"
12.13 #include "dreamcast.h"
12.14 #include "gdrom/gdrom.h"
12.15 #include "gtkui/gtkui.h"
12.16 @@ -52,7 +55,7 @@
12.17 NULL );
12.18 add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );
12.19 if( initial_dir_key != -1 ) {
12.20 - gchar *initial_path = get_absolute_path(gui_get_configurable_path(initial_dir_key));
12.21 + gchar *initial_path = get_absolute_path(get_gui_path(initial_dir_key));
12.22 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_path );
12.23 g_free(initial_path);
12.24 }
12.25 @@ -63,7 +66,7 @@
12.26 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
12.27 if( initial_dir_key != -1 ) {
12.28 gchar *end_path = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(file) );
12.29 - gui_set_configurable_path(initial_dir_key,end_path);
12.30 + set_gui_path(initial_dir_key,end_path);
12.31 g_free(end_path);
12.32 }
12.33 }
12.34 @@ -85,7 +88,7 @@
12.35 NULL );
12.36 add_file_pattern( GTK_FILE_CHOOSER(file), pattern, patname );
12.37 if( initial_dir_key != -1 ) {
12.38 - gchar *initial_path = get_absolute_path(gui_get_configurable_path(initial_dir_key));
12.39 + gchar *initial_path = get_absolute_path(get_gui_path(initial_dir_key));
12.40 gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(file), initial_path );
12.41 g_free(initial_path);
12.42 }
12.43 @@ -96,7 +99,7 @@
12.44 filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
12.45 if( initial_dir_key != -1 ) {
12.46 gchar *end_path = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(file) );
12.47 - gui_set_configurable_path(initial_dir_key,end_path);
12.48 + set_gui_path(initial_dir_key,end_path);
12.49 g_free(end_path);
12.50 }
12.51 }
12.52 @@ -171,7 +174,7 @@
12.53 {
12.54 GtkWidget *file, *preview, *frame, *align;
12.55 GtkRequisition size;
12.56 - const gchar *dir = gui_get_configurable_path(CONFIG_SAVE_PATH);
12.57 + const gchar *dir = get_gui_path(CONFIG_SAVE_PATH);
12.58 gchar *path = get_absolute_path(dir);
12.59 file = gtk_file_chooser_dialog_new( _("Load state..."), NULL,
12.60 GTK_FILE_CHOOSER_ACTION_OPEN,
12.61 @@ -201,7 +204,7 @@
12.62 if( result == GTK_RESPONSE_ACCEPT ) {
12.63 gchar *filename = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER(file) );
12.64 gchar *end_path = gtk_file_chooser_get_current_folder( GTK_FILE_CHOOSER(file) );
12.65 - gui_set_configurable_path(CONFIG_SAVE_PATH,end_path);
12.66 + set_gui_path(CONFIG_SAVE_PATH,end_path);
12.67 g_free(end_path);
12.68 dreamcast_load_state( filename );
12.69 }
13.1 --- a/src/gui.h Thu Jun 25 21:21:18 2009 +0000
13.2 +++ b/src/gui.h Fri Jun 26 05:47:04 2009 +0000
13.3 @@ -84,29 +84,6 @@
13.4 */
13.5 void gui_do_later( do_later_callback_t func );
13.6
13.7 -
13.8 -/******************* GUI helper functions *****************/
13.9 -/* The following functions effectively track the current path for each of the
13.10 - * 3 main categories (save, vmu, and disc/binary loading) independently. They
13.11 - * default to the config values, but can be updated continuously without
13.12 - * writing back to the config.
13.13 - */
13.14 -const gchar *gui_get_configurable_path(int key);
13.15 -void gui_set_configurable_path( int key, const gchar *path );
13.16 -
13.17 -/**
13.18 - * Notify the helper functions that the config paths have changed, in which
13.19 - * event they will revert to the config-specified versions.
13.20 - */
13.21 -void gui_config_paths_changed();
13.22 -
13.23 -/**
13.24 - * Return an absolute path for the given input path, as a newly allocated
13.25 - * string. If the input path is already absolute, the returned string will
13.26 - * be identical to the input string.
13.27 - */
13.28 -gchar *get_absolute_path( const gchar *path );
13.29 -
13.30 #ifdef __cplusplus
13.31 }
13.32 #endif
14.1 --- a/src/guiutil.c Thu Jun 25 21:21:18 2009 +0000
14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
14.3 @@ -1,67 +0,0 @@
14.4 -/**
14.5 - * $Id$
14.6 - *
14.7 - * GUI helper functions that aren't specific to any particular implementation.
14.8 - *
14.9 - * Copyright (c) 2009 Nathan Keynes.
14.10 - *
14.11 - * This program is free software; you can redistribute it and/or modify
14.12 - * it under the terms of the GNU General Public License as published by
14.13 - * the Free Software Foundation; either version 2 of the License, or
14.14 - * (at your option) any later version.
14.15 - *
14.16 - * This program is distributed in the hope that it will be useful,
14.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.19 - * GNU General Public License for more details.
14.20 - */
14.21 -
14.22 -#include <unistd.h>
14.23 -#include <glib/gstrfuncs.h>
14.24 -#include <glib/gutils.h>
14.25 -
14.26 -#include "gui.h"
14.27 -#include "config.h"
14.28 -
14.29 -static gchar *gui_paths[CONFIG_KEY_MAX];
14.30 -
14.31 -gchar *get_absolute_path( const gchar *in_path )
14.32 -{
14.33 - char tmp[PATH_MAX];
14.34 - if( in_path == NULL ) {
14.35 - return NULL;
14.36 - }
14.37 - if( in_path[0] == '/' || in_path[0] == 0 ) {
14.38 - return g_strdup(in_path);
14.39 - } else {
14.40 - getcwd(tmp, sizeof(tmp));
14.41 - return g_strdup_printf("%s%c%s", tmp, G_DIR_SEPARATOR, in_path);
14.42 - }
14.43 -}
14.44 -
14.45 -const gchar *gui_get_configurable_path( int key )
14.46 -{
14.47 - if( gui_paths[key] == NULL ) {
14.48 - gui_paths[key] = lxdream_get_global_config_path_value(key);
14.49 - /* If no path defined, go with the current working directory */
14.50 - if( gui_paths[key] == NULL ) {
14.51 - gui_paths[key] = get_absolute_path(".");
14.52 - }
14.53 - }
14.54 - return gui_paths[key];
14.55 -}
14.56 -
14.57 -void gui_set_configurable_path( int key, const gchar *path )
14.58 -{
14.59 - g_free(gui_paths[key]);
14.60 - gui_paths[key] = g_strdup(path);
14.61 -}
14.62 -
14.63 -void gui_config_paths_changed()
14.64 -{
14.65 - int i;
14.66 - for( i=0; i < CONFIG_KEY_MAX; i++ ) {
14.67 - g_free(gui_paths[i]);
14.68 - gui_paths[i] = NULL;
14.69 - }
14.70 -}
15.1 --- a/src/lxdream.h Thu Jun 25 21:21:18 2009 +0000
15.2 +++ b/src/lxdream.h Fri Jun 26 05:47:04 2009 +0000
15.3 @@ -87,11 +87,6 @@
15.4 #define DEBUG( ... ) log_message( NULL, EMIT_DEBUG, MODULE_NAME, __VA_ARGS__ )
15.5 #define TRACE( ... ) log_message( NULL, EMIT_TRACE, MODULE_NAME, __VA_ARGS__ )
15.6
15.7 -/****************** System paths ****************/
15.8 -const char *get_sysconf_path();
15.9 -const char *get_locale_path();
15.10 -const char *get_plugin_path();
15.11 -const char *get_user_data_path();
15.12
15.13 #ifdef HAVE_FASTCALL
15.14 #define FASTCALL __attribute__((regparm(2)))
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/src/lxpaths.c Fri Jun 26 05:47:04 2009 +0000
16.3 @@ -0,0 +1,158 @@
16.4 +/**
16.5 + * $Id$
16.6 + *
16.7 + * GUI helper functions that aren't specific to any particular implementation.
16.8 + *
16.9 + * Copyright (c) 2009 Nathan Keynes.
16.10 + *
16.11 + * This program is free software; you can redistribute it and/or modify
16.12 + * it under the terms of the GNU General Public License as published by
16.13 + * the Free Software Foundation; either version 2 of the License, or
16.14 + * (at your option) any later version.
16.15 + *
16.16 + * This program is distributed in the hope that it will be useful,
16.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.19 + * GNU General Public License for more details.
16.20 + */
16.21 +
16.22 +#include <ctype.h>
16.23 +#include <unistd.h>
16.24 +#include <wordexp.h>
16.25 +#include <glib/gstrfuncs.h>
16.26 +#include <glib/gutils.h>
16.27 +
16.28 +#include "gui.h"
16.29 +#include "config.h"
16.30 +
16.31 +static gchar *gui_paths[CONFIG_KEY_MAX];
16.32 +
16.33 +/**
16.34 + * Test if we need to escape a path to prevent substitution mangling.
16.35 + * @return TRUE if the input value contains any character that doesn't
16.36 + * match [a-zA-Z0-9._@%/] (this will escape slightly more than it needs to,
16.37 + * but is safe)
16.38 + */
16.39 +static gboolean path_needs_escaping( const gchar *value )
16.40 +{
16.41 + const gchar *p = value;
16.42 + while( *p ) {
16.43 + if( !isalnum(*p) && *p != '.' && *p != '_' &&
16.44 + *p != '@' && *p != '%' && *p != '/' ) {
16.45 + return TRUE;
16.46 + }
16.47 + p++;
16.48 + }
16.49 + return FALSE;
16.50 +}
16.51 +
16.52 +gchar *get_escaped_path( const gchar *value )
16.53 +{
16.54 + if( value != NULL && path_needs_escaping(value) ) {
16.55 + /* Escape with "", and backslash the remaining characters:
16.56 + * \ " $ `
16.57 + */
16.58 + char buf[strlen(value)*2+3];
16.59 + const char *s = value;
16.60 + char *p = buf;
16.61 + *p++ = '\"';
16.62 + while( *s ) {
16.63 + if( *s == '\\' || *s == '"' || *s == '$' || *s == '`' ) {
16.64 + *p++ = '\\';
16.65 + }
16.66 + *p++ = *s++;
16.67 + }
16.68 + *p++ = '\"';
16.69 + *p = '\0';
16.70 + return g_strdup(buf);
16.71 + } else {
16.72 + return g_strdup(value);
16.73 + }
16.74 +}
16.75 +
16.76 +gchar *get_expanded_path( const gchar *input )
16.77 +{
16.78 + wordexp_t we;
16.79 + if( input == NULL ) {
16.80 + return NULL;
16.81 + }
16.82 + memset(&we,0,sizeof(we));
16.83 + int result = wordexp(input, &we, WRDE_NOCMD);
16.84 + if( result != 0 || we.we_wordc == 0 ) {
16.85 + /* On failure, return the original input unchanged */
16.86 + return g_strdup(input);
16.87 + } else {
16.88 + /* On success, concatenate all 'words' together into a single
16.89 + * space-separated string
16.90 + */
16.91 + int length = we.we_wordc, i;
16.92 + gchar *result, *p;
16.93 +
16.94 + for( i=0; i<we.we_wordc; i++ ) {
16.95 + length += strlen(we.we_wordv[i]);
16.96 + }
16.97 + p = result = g_malloc(length);
16.98 + for( i=0; i<we.we_wordc; i++ ) {
16.99 + if( i != 0 )
16.100 + *p++ = ' ';
16.101 + strcpy( p, we.we_wordv[i] );
16.102 + p += strlen(p);
16.103 + }
16.104 + wordfree(&we);
16.105 + return result;
16.106 + }
16.107 +}
16.108 +
16.109 +gchar *get_absolute_path( const gchar *in_path )
16.110 +{
16.111 + char tmp[PATH_MAX];
16.112 + if( in_path == NULL ) {
16.113 + return NULL;
16.114 + }
16.115 + if( in_path[0] == '/' || in_path[0] == 0 ) {
16.116 + return g_strdup(in_path);
16.117 + } else {
16.118 + getcwd(tmp, sizeof(tmp));
16.119 + return g_strdup_printf("%s%c%s", tmp, G_DIR_SEPARATOR, in_path);
16.120 + }
16.121 +}
16.122 +
16.123 +gchar *get_filename_at( const gchar *at, const gchar *filename )
16.124 +{
16.125 + char tmp[PATH_MAX];
16.126 + char *p = strrchr( filename, '/' );
16.127 + if( p == NULL ) {
16.128 + /* No path at all, so just return filename */
16.129 + return g_strdup(filename);
16.130 + } else {
16.131 + int off = p-filename;
16.132 + return g_strdup_printf("%.*s%c%s", off, at, G_DIR_SEPARATOR, filename );
16.133 + }
16.134 +}
16.135 +
16.136 +const gchar *get_gui_path( int key )
16.137 +{
16.138 + if( gui_paths[key] == NULL ) {
16.139 + gui_paths[key] = lxdream_get_global_config_path_value(key);
16.140 + /* If no path defined, go with the current working directory */
16.141 + if( gui_paths[key] == NULL ) {
16.142 + gui_paths[key] = get_absolute_path(".");
16.143 + }
16.144 + }
16.145 + return gui_paths[key];
16.146 +}
16.147 +
16.148 +void set_gui_path( int key, const gchar *path )
16.149 +{
16.150 + g_free(gui_paths[key]);
16.151 + gui_paths[key] = g_strdup(path);
16.152 +}
16.153 +
16.154 +void reset_gui_paths()
16.155 +{
16.156 + int i;
16.157 + for( i=0; i < CONFIG_KEY_MAX; i++ ) {
16.158 + g_free(gui_paths[i]);
16.159 + gui_paths[i] = NULL;
16.160 + }
16.161 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/src/lxpaths.h Fri Jun 26 05:47:04 2009 +0000
17.3 @@ -0,0 +1,97 @@
17.4 +/**
17.5 + * $Id$
17.6 + *
17.7 + * Various path definitions and helper functions
17.8 + *
17.9 + * Copyright (c) 2005 Nathan Keynes.
17.10 + *
17.11 + * This program is free software; you can redistribute it and/or modify
17.12 + * it under the terms of the GNU General Public License as published by
17.13 + * the Free Software Foundation; either version 2 of the License, or
17.14 + * (at your option) any later version.
17.15 + *
17.16 + * This program is distributed in the hope that it will be useful,
17.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
17.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.19 + * GNU General Public License for more details.
17.20 + */
17.21 +
17.22 +#ifndef lxdream_paths_H
17.23 +#define lxdream_paths_H
17.24 +
17.25 +/****************** System paths ****************/
17.26 +/**
17.27 + * Location of the shared lxdreamrc (e.g. /usr/local/etc/lxdreamrc)
17.28 + */
17.29 +const char *get_sysconf_path();
17.30 +
17.31 +/**
17.32 + * Location of the message catalogs (e.g. /usr/local/share/locale)
17.33 + */
17.34 +const char *get_locale_path();
17.35 +
17.36 +/**
17.37 + * Location of the plugins, if any (e.g. /usr/local/lib/lxdream)
17.38 + */
17.39 +const char *get_plugin_path();
17.40 +
17.41 +/**
17.42 + * Location of the current user's data path (e.g. ~/.lxdream)
17.43 + */
17.44 +const char *get_user_data_path();
17.45 +
17.46 +/******************** Path helpers *****************/
17.47 +
17.48 +/**
17.49 + * Escape a pathname if needed to prevent shell substitution.
17.50 + * @return a newly allocated string (or NULL if the input is NULL)
17.51 + */
17.52 +gchar *get_escaped_path( const gchar *name );
17.53 +
17.54 +/**
17.55 + * Expand a pathname according to standard shell substitution rules
17.56 + * (excluding command substitutions).
17.57 + * @return a newly allocated string (or NULL if the input is NULL)
17.58 + */
17.59 +gchar *get_expanded_path( const gchar *name );
17.60 +
17.61 +/**
17.62 + * Return an absolute path for the given input path, as a newly allocated
17.63 + * string. If the input path is already absolute, the returned string will
17.64 + * be identical to the input string.
17.65 + */
17.66 +gchar *get_absolute_path( const gchar *path );
17.67 +
17.68 +/**
17.69 + * Construct a filename in the same directory as the file at. That is,
17.70 + * if at is "/tmp/foo" and filename = "bar", the function returns
17.71 + * "/tmp/bar".
17.72 + * @return a newly allocated string that must be released by the caller.
17.73 + */
17.74 +gchar *get_filename_at( const gchar *at, const gchar *filename );
17.75 +
17.76 +
17.77 +/********************* GUI Paths ***********************/
17.78 +/* The following functions provide a cache for the most recently accessed
17.79 + * path for each config key (ie for GUI file open/save dialogs)
17.80 + */
17.81 +/**
17.82 + * Get the path corresponding to the given global config key
17.83 + */
17.84 +const gchar *get_gui_path(int key);
17.85 +
17.86 +/**
17.87 + * Override the path for the given global config key, without changing the
17.88 + * underlying configuration.
17.89 + */
17.90 +void set_gui_path( int key, const gchar *path );
17.91 +
17.92 +/**
17.93 + * Notify the helper functions that the config paths have changed, in which
17.94 + * event they will revert to the config-specified versions.
17.95 + */
17.96 +void reset_gui_paths();
17.97 +
17.98 +
17.99 +
17.100 +#endif /* !lxdream_paths_H */
18.1 --- a/src/main.c Thu Jun 25 21:21:18 2009 +0000
18.2 +++ b/src/main.c Fri Jun 26 05:47:04 2009 +0000
18.3 @@ -21,6 +21,7 @@
18.4 #include <unistd.h>
18.5 #include <getopt.h>
18.6 #include "lxdream.h"
18.7 +#include "lxpaths.h"
18.8 #include "gettext.h"
18.9 #include "mem.h"
18.10 #include "dreamcast.h"
19.1 --- a/src/plugin.c Thu Jun 25 21:21:18 2009 +0000
19.2 +++ b/src/plugin.c Fri Jun 26 05:47:04 2009 +0000
19.3 @@ -23,7 +23,7 @@
19.4 #include <glib/gmem.h>
19.5 #include <glib/gstrfuncs.h>
19.6 #include "plugin.h"
19.7 -
19.8 +#include "lxpaths.h"
19.9
19.10 #ifdef APPLE_BUILD
19.11 #define SOEXT ".dylib"
.