home *** CD-ROM | disk | FTP | other *** search
- /*
- * Bob_Vadnais@pdh.com Sun Jun 27 13:46:11 PDT 1993
- *
- * Interface Builder palette that preserves the CVS directory inside a
- * nib documement.
- *
- * Wouldn't it be nice if all apps had a document controller paradigm?
- * Then we could solve this same problem with Edit wiping out the CVS
- * directory inside .rtfd documents.
- */
-
- #import "CVSPalette.h"
-
- @implementation CVSPalette
-
- extern char *sys_errlist[];
-
- #define TAR "gnutar"
-
- - finishInstantiate
- /*
- * Register ourselves as an IBDocumentController so we will receive
- * didSaveDocument: messages from IB whenever the user saves a document.
- *
- * Due to an apparent bug in IB, we won't get registered correctly if
- * we're autoloaded at IB launch time, hence the delayed registration.
- */
- {
- [NXApp perform:@selector(registerDocumentController:)
- with:self afterDelay:10000 cancelPrevious:NO];
-
- return self;
- }
-
- - didSaveDocument:theDocument
- {
- char path[MAXPATHLEN+10];
- int pathlen;
-
- [theDocument getDocumentPathIn:path];
- pathlen = strlen(path);
- strcpy(path + pathlen, "~/CVS");
-
- if (access(path, R_OK|X_OK) == 0) {
-
- char cmdbuf[MAXPATHLEN * 2 + 32];
- path[pathlen] = 0; // Chop off the ~/CVS we added
- sprintf(cmdbuf, TAR " cCf %s~ - CVS | " TAR " xpCf %s -", path, path);
- if (system(cmdbuf) < 0) {
- NXRunAlertPanel("Error", "Unable to copy %s~/CVS into %s: %s",
- 0, 0, 0, path, path, sys_errlist[errno]);
- }
- }
-
- return self;
- }
-
- @end
-