Skip to content

Commit

Permalink
[PHP] Remove platform dependency from file path (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
ackintosh authored and jmini committed Jul 20, 2018
1 parent eeda132 commit af9d57e
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ public void processOpts() {
additionalProperties.put("escapedInvokerPackage", invokerPackage.replace("\\", "\\\\"));

// make api and model src path available in mustache template
additionalProperties.put("apiSrcPath", "." + File.separator + toSrcPath(apiPackage, srcBasePath));
additionalProperties.put("modelSrcPath", "." + File.separator + toSrcPath(modelPackage, srcBasePath));
additionalProperties.put("apiTestPath", "." + File.separator + testBasePath + File.separator + apiDirName);
additionalProperties.put("modelTestPath", "." + File.separator + testBasePath + File.separator + modelDirName);
additionalProperties.put("apiSrcPath", "./" + toSrcPath(apiPackage, srcBasePath));
additionalProperties.put("modelSrcPath", "./" + toSrcPath(modelPackage, srcBasePath));
additionalProperties.put("apiTestPath", "./" + testBasePath + "/" + apiDirName);
additionalProperties.put("modelTestPath", "./" + testBasePath + "/" + modelDirName);

// make api and model doc path available in mustache template
additionalProperties.put("apiDocPath", apiDocPath);
Expand All @@ -255,7 +255,7 @@ public String toPackagePath(String packageName, String basePath) {
public String toSrcPath(String packageName, String basePath) {
packageName = packageName.replace(invokerPackage, ""); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
if (basePath != null && basePath.length() > 0) {
basePath = basePath.replaceAll("[\\\\/]?$", "") + File.separatorChar; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
basePath = basePath.replaceAll("[\\\\/]?$", "") + '/'; // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
}

String regFirstPathSeparator;
Expand All @@ -274,7 +274,7 @@ public String toSrcPath(String packageName, String basePath) {

return (basePath
// Replace period, backslash, forward slash with file separator in package name
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement(File.separator))
+ packageName.replaceAll("[\\.\\\\/]", Matcher.quoteReplacement("/"))
// Trim prefix file separators from package path
.replaceAll(regFirstPathSeparator, ""))
// Trim trailing file separators from the overall path
Expand Down

0 comments on commit af9d57e

Please sign in to comment.