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

[Sc-devel] findHelpFile on non-osX



Is there a version of String:findHelpFile for non-osx (i.e. windows, linux)?

If not we (Eckard and me) implemented one [1]. Anyone think that thos could be of usage? I'm a bit unsure where to put it, though... I don't know the conventions for platform-dependecy classes good enough... BtW, it also works on osx... (not that we should use it there, we already have a primitive for it :-)

regards
Till

[1]

// 2007, lfsaw.de, eriedenklau   ( We like recursive programming :-)
+ String {
	findHelpFile {
		var result = nil;
[Platform.helpDir, Platform.userExtensionDir, Platform.systemExtensionDir].do{|path|
			result = this.prFindHelpFile(path);
			result.notNil.if{^result}
		}
		^result
	}

	prFindHelpFile {|startPath|
		var sym, parts, result = nil, paths, res;

		paths = "%%*".format(startPath, Platform.pathSeparator).pathMatch;
		result = paths.detect{|path|
			var basename, extension;
			basename = path.basename.split($.).first;
			extension = path.split($.).last;
PathName(path).isFile && {basename == this && {extension == "html"} }
	 	};
	  	result.isNil.if({
			paths.do {|path|
	     		res = this.prFindHelpFile(path);
	     		res.notNil.if{^res}
			};
	  	});
	  	^result;
	}
}