From: <Mee...@us...> - 2011-10-01 15:55:19
|
Revision: 3700 http://sc2.svn.sourceforge.net/sc2/?rev=3700&view=rev Author: Meep-Eep Date: 2011-10-01 15:55:13 +0000 (Sat, 01 Oct 2011) Log Message: ----------- Don't require the 'shadow' dir in addon packs, from Alex. Modified Paths: -------------- trunk/sc2/ChangeLog trunk/sc2/src/libs/uio/io.c trunk/sc2/src/libs/uio/io.h trunk/sc2/src/options.c Modified: trunk/sc2/ChangeLog =================================================================== --- trunk/sc2/ChangeLog 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/ChangeLog 2011-10-01 15:55:13 UTC (rev 3700) @@ -1,4 +1,5 @@ Changes towards version 0.8: +- Don't require the 'shadow' dir in addon packs, from Alex - Make use of GAME_STATE_FILE consistently, from Scott A. Colcord - Fixed unconst(), from Scott A. Colcord - Fixes to a few small bugs in UIO which shouldn't have had an impact on Modified: trunk/sc2/src/libs/uio/io.c =================================================================== --- trunk/sc2/src/libs/uio/io.c 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/src/libs/uio/io.c 2011-10-01 15:55:13 UTC (rev 3700) @@ -287,6 +287,103 @@ } } +// Mount a repository directory into same repository at a different location +// From fossil. +uio_MountHandle * +uio_transplantDir(const char *mountPoint, uio_DirHandle *sourceDir, int flags, + uio_MountHandle *relative) { + uio_MountInfo *relativeInfo; + int numPDirHandles; + uio_PDirHandle **pDirHandles; + uio_MountTreeItem **treeItems; + int i; + uio_MountHandle *handle = NULL; + + if ((flags & uio_MOUNT_RDONLY) != uio_MOUNT_RDONLY) { + // Only read-only transplants supported atm + errno = ENOSYS; + return NULL; + } + + switch (flags & uio_MOUNT_LOCATION_MASK) { + case uio_MOUNT_TOP: + case uio_MOUNT_BOTTOM: + if (relative != NULL) { + errno = EINVAL; + return NULL; + } + relativeInfo = NULL; + break; + case uio_MOUNT_BELOW: + case uio_MOUNT_ABOVE: + if (relative == NULL) { + errno = EINVAL; + return NULL; + } + relativeInfo = relative->mountInfo; + break; + default: + abort(); + } + + if (mountPoint[0] == '/') + mountPoint++; + if (!validPathName(mountPoint, strlen(mountPoint))) { + errno = EINVAL; + return NULL; + } + + if (uio_getPathPhysicalDirs(sourceDir, "", 0, + &pDirHandles, &numPDirHandles, &treeItems) == -1) { + // errno is set + return NULL; + } + if (numPDirHandles == 0) { + errno = ENOENT; + return NULL; + } + + // TODO: We only transplant the first read-only physical dir that we find + // Maybe transplant all of them? We would then have several + // uio_MountHandles to return. + for (i = 0; i < numPDirHandles; ++i) { + uio_PDirHandle *pDirHandle = pDirHandles[i]; + uio_MountInfo *oldMountInfo = treeItems[i]->mountInfo; + uio_Repository *rep = oldMountInfo->mountHandle->repository; + uio_MountInfo *mountInfo; + uio_MountTree *mountTree; + + // Only interested in read-only dirs in this incarnation + if (!uio_mountInfoIsReadOnly(oldMountInfo)) + continue; + + mountInfo = uio_MountInfo_new(oldMountInfo->fsID, NULL, pDirHandle, + uio_strdup(""), oldMountInfo->autoMount, NULL, flags); + // New mount references the same handles + uio_PDirHandle_ref(pDirHandle); + uio_PRoot_refMount(pDirHandle->pRoot); + + uio_repositoryAddMount(rep, mountInfo, + flags & uio_MOUNT_LOCATION_MASK, relativeInfo); + mountTree = uio_mountTreeAddMountInfo(rep, rep->mountTree, + mountInfo, mountPoint, flags & uio_MOUNT_LOCATION_MASK, + relativeInfo); + // mountTree is the node in rep->mountTree where mountInfo leads to + mountInfo->mountTree = mountTree; + mountInfo->mountHandle = uio_MountHandle_new(rep, mountInfo); + handle = mountInfo->mountHandle; + break; + } + + uio_PDirHandles_delete(pDirHandles, numPDirHandles); + uio_free(treeItems); + + if (handle == NULL) + errno = ENOENT; + + return handle; +} + int uio_unmountDir(uio_MountHandle *mountHandle) { uio_PRoot *pRoot; Modified: trunk/sc2/src/libs/uio/io.h =================================================================== --- trunk/sc2/src/libs/uio/io.h 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/src/libs/uio/io.h 2011-10-01 15:55:13 UTC (rev 3700) @@ -82,6 +82,12 @@ const char *inPath, uio_AutoMount **autoMount, int flags, uio_MountHandle *relative); +// Mount a repository directory into same repository at a different +// location. +// From fossil. +uio_MountHandle *uio_transplantDir(const char *mountPoint, + uio_DirHandle *sourceDir, int flags, uio_MountHandle *relative); + // Unmount a previously mounted dir. int uio_unmountDir(uio_MountHandle *mountHandle); Modified: trunk/sc2/src/options.c =================================================================== --- trunk/sc2/src/options.c 2011-10-01 15:40:10 UTC (rev 3699) +++ trunk/sc2/src/options.c 2011-10-01 15:55:13 UTC (rev 3700) @@ -571,6 +571,14 @@ { log_add (log_Debug, "Mounting shadow content of '%s' addon", addon); mountDirZips (shadowDir, "/", uio_MOUNT_ABOVE, contentMountHandle); + // Mount non-zipped shadow content + if (uio_transplantDir ("/", shadowDir, uio_MOUNT_RDONLY | + uio_MOUNT_ABOVE, contentMountHandle) == NULL) + { + log_add (log_Warning, "Warning: Could not mount shadow content" + " of '%s': %s.", addon, strerror (errno)); + } + uio_closeDir (shadowDir); } uio_closeDir (addonDir); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |