Revision 3 (by moose, 2006/07/23 22:51:40) file mod
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title /><meta name="generator" content="StarOffice/OpenOffice.org XSLT (http://xml.openoffice.org/sx2ml)" /><meta name="author" content="Thomas Fjellstrom" /><meta name="created" content="2006-07-23T15:08:10" /><meta name="changedby" content="Thomas Fjellstrom" /><meta name="changed" content="2006-07-23T16:31:12" /><base href="." /><style type="text/css">
	@page { size: 8.5inch 11inch; margin-top: 0.7874inch; margin-bottom: 0.7874inch; margin-left: 0.7874inch; margin-right: 0.7874inch }
	table { border-collapse:collapse; border-spacing:0; empty-cells:show }
	td, th { vertical-align:top; }
	h1, h2, h3, h4, h5, h6 { clear:both }
	ol, ul { padding:0; }
	* { margin:0; }
	*.Caption { font-family:'Times New Roman'; font-size:12pt; margin-top:0.0835in; margin-bottom:0.0835in; font-style:italic; }
	*.Endnote { font-family:'Times New Roman'; font-size:10pt; margin-left:0.1965in; margin-right:0in; text-indent:-0.1965inch; }
	*.Footer { font-family:'Times New Roman'; font-size:12pt; }
	*.Footnote { font-family:'Times New Roman'; font-size:10pt; margin-left:0.1965in; margin-right:0in; text-indent:-0.1965inch; }
	*.Heading { font-family:Arial; font-size:14pt; margin-top:0.1665in; margin-bottom:0.0835in; }
	*.Index { font-family:'Times New Roman'; font-size:12pt; }
	*.List { font-family:'Times New Roman'; font-size:12pt; margin-top:0in; margin-bottom:0.0835in; }
	*.P1 { font-family:'Times New Roman'; font-size:16pt; text-align:center ! important; font-weight:bold; }
	*.P10 { font-family:'Times New Roman'; font-size:12pt; text-align:left ! important; font-weight:bold; }
	*.P11 { font-family:'Times New Roman'; font-size:12pt; text-align:left ! important; }
	*.P2 { font-family:'Times New Roman'; font-size:14pt; text-align:center ! important; }
	*.P3 { font-family:'Times New Roman'; font-size:12pt; text-align:left ! important; }
	*.P4 { font-family:'Times New Roman'; font-size:14pt; text-align:left ! important; }
	*.P5 { font-family:'Times New Roman'; font-size:12pt; text-align:left ! important; }
	*.P6 { font-family:'Times New Roman'; font-size:10pt; margin-left:0in; margin-right:0in; text-indent:0inch; }
	*.P7 { font-family:'Times New Roman'; font-size:12pt; text-align:left ! important; }
	*.P8 { font-family:'Times New Roman'; font-size:14pt; text-align:left ! important; font-weight:normal; }
	*.P9 { font-family:Courier; font-size:8pt; text-align:left ! important; }
	*.Standard { font-family:'Times New Roman'; font-size:12pt; }
	*.Textbody { font-family:'Times New Roman'; font-size:12pt; margin-top:0in; margin-bottom:0.0835in; }
	*.BulletSymbols { font-family:StarSymbol; font-size:9pt; }
	*.Endnoteanchor { vertical-align:sup; }
	*.EndnoteSymbol { }
	*.Footnoteanchor { vertical-align:sup; }
	*.FootnoteSymbol { }
	*.Internetlink { color:#000080; text-decoration:underline; }
	*.NumberingSymbols { }
	*.T1 { }
	*.T2 { font-weight:bold; }
	*.T3 { font-style:italic; }
	</style></head><body dir="ltr"><p class="P1"><span class="T1">Allegro 4.3</span> </p><p class="P2">File System Proposal </p><p class="P3"> </p><p class="P4">History </p><p class="P3">Allegro has in the past been very inflexible wrt files, and file system handling. It provided little in the way of useful functions to handle platform dependent, and independent paths, had very hackish methods for getting the path to the program's directory, and creating additional paths based on that. </p><p class="P3"> </p><p class="P4">Now </p><p class="P3">What I propose is a new DRIVER structure akin to the GFX_DRIVERs and SYSTEM_DRIVERs. This structure would contain hooks for all of the necessary driver methods dealing with paths, files, file systems, directories, and other related items. </p><p class="P3"> </p><p class="P4">Necessary Hooks </p><ul style="margin-left:0.5cm;"><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">open </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">read </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">write </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">close </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">stat </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">opendir </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">readdir </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">closedir </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">mkstmp (create a temp file, return handle) </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">getcwd (get current working directory) </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">getprogramdir (wip name, gets directory the exe lives in) </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">getdatadir (wip again, gets dir to store app data in) </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">native2vfs (convert paths from os native format, to vfs format)</p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">vfs2native (ditto, in reverse) </p></li><li class="P5" style="margin-left:0cm;"><p class="P5" style="margin-left:0.25cm;">chdir </p></li></ul><p class="P3"> </p><p class="P4">Nice to have hooks </p><ul style="margin-left:0.5cm;"><li class="P7" style="margin-left:0cm;"><p class="P7" style="margin-left:0.25cm;">add_search_path (adds a path to look at for relatively specified paths in open, etc) </p></li></ul><p class="P3"> </p><p class="P8">Proposed usage </p><p class="P9"> </p><p class="P10">Basic </p><p class="P9">#install &lt;allegro.h&gt; </p><p class="P9">install_vfs(VFS_STDIO); </p><p class="P9">AL_BITMAP *foo = al_load_bitmap(“foo.bmp”); </p><p class="P9"> </p><p class="P3"><span class="T2">Advanced</span> (the vfs should probably “automount” the main vfs ie: stdio or win32, or whatever)</p><p class="P9">#include &lt;allegro.h&gt; </p><p class="P9">#include &lt;vfs.h&gt; </p><p class="P9">#include &lt;vfs/stdio.h&gt; </p><p class="P9">#include &lt;vfs/zip.h&gt; </p><p class="P9"> </p><p class="P9">install_vfs(VFS_NONAMEVFS); // yeah, don't have a name for my vfs yet, this'll have to do. </p><p class="P9"> </p><p class="P9">char *data_dir = al_data_dir(); </p><p class="P9">VFS *stdio = vfs_stdio_create(data_dir, “/”); // arg1 is what to set as the root dir if this VFS, and arg2 is where in the VFS root to mount it. In this case, its the absolute root. </p><p class="P9">VFS *archive = vfs_zip_create(“characters.zip”, “/characters”); // (what, where) </p><p class="P9">AL_FILE *main_character = al_fopen(“/characters/main.chr”); </p><p class="P9">// or </p><p class="P9">VFS_STREAM *main_character = vfs_open(“/characters/main.chr”); </p><p class="P9">// etc </p><p class="P9"> </p><p class="P11">You might be wondering where the zip file will be opened from, well its based on the root “/”, and the current dir (which defaults to the vfs “/”, if vfs_chdir/al_chdir is never called.). If you think it should be solely based on the libc equivalent, remember the vfs isn't guaranteed to only access the normal file system, afaik, libc's chdir won't know how to chdir/getcwd inside a VFS mounted zip file. And the reason I chose “/” as default, is because you are generally going to have the root of your VFS as the starting point for all your data, which is I think the expected behavior. </p><p class="P11"> </p><p class="P11">This is a <span class="T3">work in progress</span>.</p></body></html>