Trying to resolve the link issue in windows gh-231

This commit is contained in:
Llewellyn van der Merwe 2019-03-13 14:20:51 +02:00
parent f31c8968e7
commit da16b61ffb
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
7 changed files with 95 additions and 13 deletions

View File

@ -146,11 +146,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 9th March, 2019
+ *Last Build*: 13th March, 2019
+ *Version*: 2.9.13
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **203581**
+ *Line count*: **203649**
+ *Field count*: **1114**
+ *File count*: **1337**
+ *Folder count*: **209**

View File

@ -146,11 +146,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 9th March, 2019
+ *Last Build*: 13th March, 2019
+ *Version*: 2.9.13
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **203581**
+ *Line count*: **203649**
+ *Field count*: **1114**
+ *File count*: **1337**
+ *Folder count*: **209**

View File

@ -5807,7 +5807,7 @@ class Get
$commentType = 0;
// make sure we have the path correct (the script file is not in admin path for example)
// there may be more... will nead to keep our eye on this... since files could be moved during install
$file = str_replace('./', '', $file);
$file = str_replace( './', '', $file); # TODO (windows path issues)
if ($file !== 'script.php')
{
$path = $target . '/' . $file;
@ -5981,6 +5981,8 @@ class Get
$hasharray = array_slice($fingerPrint, -$inFinger, $getFinger, true);
$hasleng = count($hasharray);
$hashtarget = $hasleng . '__' . md5(implode('', $hasharray));
// for good practice
ComponentbuilderHelper::fixPath($path);
// all new records we can do a buldk insert
if ($i === 1 || !$id)
{

View File

@ -830,7 +830,8 @@ class Structure extends Get
// set the template folder path
$templatePath = (isset($details->custom) && $details->custom) ? (($details->custom !== 'full') ? $this->templatePathCustom . '/' : '') : $this->templatePath . '/';
// set the final paths
$currentFullPath = str_replace('//', '/', $templatePath . '/' . $item);
$currentFullPath = (preg_match('/^[a-z]:/i', $item)) ? $item : $templatePath . '/' . $item;
$currentFullPath = str_replace('//', '/', $currentFullPath);
$packageFullPath = str_replace('//', '/', $path . '/' . $new);
$zipFullPath = str_replace('//', '/', $zipPath . '/' . $new);
// now move the file
@ -1287,17 +1288,22 @@ class Structure extends Get
$pointer_tracker = 'h';
foreach ($this->componentData->folders as $custom)
{
// by default custom path is true
$customPath = 'custom';
// for good practice
ComponentbuilderHelper::fixPath($custom, array('path', 'folder', 'folderpath'));
// fix custom path
if (isset($custom['path']) && ComponentbuilderHelper::checkString($custom['path']))
{
$custom['path'] = trim($custom['path'], '/');
}
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path folder
if (!isset($custom['folder']) && isset($custom['folderpath']))
{
$custom['folder'] = '/' . trim($custom['folderpath'], '/');
// set the folder path with / if does not have a drive/windows full path
$custom['folder'] = (preg_match('/^[a-z]:/i', $custom['folderpath']))
? trim($custom['folderpath'], '/')
: '/' . trim($custom['folderpath'], '/');
// update the dynamic path
$custom['folder'] = $this->updateDynamicPath($custom['folder']);
// remove the file path
@ -1369,11 +1375,17 @@ class Structure extends Get
$pointer_tracker = 'h';
foreach ($this->componentData->files as $custom)
{
// for good practice
ComponentbuilderHelper::fixPath($custom, array('path', 'file', 'filepath'));
// by default custom path is true
$customPath = 'custom';
// set full path if this is a full path file
if (!isset($custom['file']) && isset($custom['filepath']))
{
$custom['file'] = '/' . trim($custom['filepath'], '/');
// set the file path with / if does not have a drive/windows full path
$custom['file'] = (preg_match('/^[a-z]:/i', $custom['filepath']))
? trim($custom['filepath'], '/')
: '/' . trim($custom['filepath'], '/');
// update the dynamic path
$custom['file'] = $this->updateDynamicPath($custom['file']);
// remove the file path

View File

@ -407,7 +407,41 @@ abstract class ComponentbuilderHelper
}
return false;
}
/**
* Fix the path to work in the JCB script <-- (main issue here)
* Since we need / slash in all paths, for the JCB script even if it is Windows
* and since MS works with both forward and back slashes
* we just convert all slashes to forward slashes
*
* THIS is just my hack (fix) if you know a better way! speak-up!
*
* @param mix $values the array of paths or the path as a string
* @param array $targets paths to target
*
* @return string
*
*/
public static function fixPath(&$values, $targets = array())
{
// if multiple to gets searched and fixed
if (self::checkArray($values) && self::checkArray($targets))
{
foreach ($targets as $target)
{
if (isset($values[$target]) && strpos($values[$target], '\\') !== false)
{
$values[$target] = str_replace('\\', '/', $values[$target]);
}
}
}
// if just a string
elseif (self::checkString($values) && strpos($values, '\\') !== false)
{
$values = str_replace('\\', '/', $values);
}
}
/**
* get all the file paths in folder and sub folders
*

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>9th March, 2019</creationDate>
<creationDate>13th March, 2019</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -407,7 +407,41 @@ abstract class ComponentbuilderHelper
}
return false;
}
/**
* Fix the path to work in the JCB script <-- (main issue here)
* Since we need / slash in all paths, for the JCB script even if it is Windows
* and since MS works with both forward and back slashes
* we just convert all slashes to forward slashes
*
* THIS is just my hack (fix) if you know a better way! speak-up!
*
* @param mix $values the array of paths or the path as a string
* @param array $targets paths to target
*
* @return string
*
*/
public static function fixPath(&$values, $targets = array())
{
// if multiple to gets searched and fixed
if (self::checkArray($values) && self::checkArray($targets))
{
foreach ($targets as $target)
{
if (isset($values[$target]) && strpos($values[$target], '\\') !== false)
{
$values[$target] = str_replace('\\', '/', $values[$target]);
}
}
}
// if just a string
elseif (self::checkString($values) && strpos($values, '\\') !== false)
{
$values = str_replace('\\', '/', $values);
}
}
/**
* get all the file paths in folder and sub folders
*