1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-18 01:03:14 +00:00

Update documentation

This commit is contained in:
Bryan Roe
2022-10-11 00:14:24 -07:00
parent f811d1fc93
commit f5283e30ae
3 changed files with 81 additions and 18 deletions

View File

@@ -14,23 +14,35 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
//
// Helper module, to make path processing consistent beween platforms.
//
//
// Creates a path string, using a specified path (path1), filename (path2), and whether to use the Current Working Directory (useCWD)
//
function makePath(path1, path2, useCWD)
{
if (useCWD != null && useCWD)
{
// If useCWD is specified, path1 is ignored, and it will instead use the current process's working directory
// We're going to take the leaf folder of path1, and place it in the working folder
var tokens = process.cwd().split(process.platform == 'win32' ? '\\' : '/');
tokens.pop();
tokens.push(path1.split(process.platform == 'win32' ? '\\' : '/').pop());
tokens.push(path1.split(process.platform == 'win32' ? '\\' : '/').pop());
path1 = tokens.join(process.platform == 'win32' ? '\\' : '/');
}
if (path2.startsWith('.'))
{
// We're going to substitute .exe with the specified extension in path2
if (path1.toLowerCase().endsWith('.exe')) { path1 = path1.substring(0, path1.length - 4); }
path1 += path2;
}
else
{
// We're going to take path1, remove the trailing delimiter, and append path2, then convert all the delimiters back to the OS specific delimter
var tokens = path1.split(process.platform == 'win32' ? '\\' : '/');
tokens.pop();
tokens.push(path2);