Fix directory creation and filename extension handling
Description
Fixes a bug where xgen assumes that the output path provided by the user is a directory. This removes the call to PrepareOutputDir from xgen.go, but this should be fine because PrepareOutputDir is also called, correctly, in parser.go.
Fixes a bug where the language-specific generator code assumes that the output path does not contain the file extension. This commit adds a helper function called FileWithExtension that checks to see if the extension already exists on the filename and does not add it again if it does.
Related Issue
Fixes #56
Motivation and Context
How Has This Been Tested
Unit tests and manual tests (see below).
$ go run cmd/xgen/xgen.go -l Java -i test/xsd/base64.xsd -o output.java
done
$ ls -la | grep output
-rw-rw-r-- 1 bpursley bpursley 2066 Jul 20 10:05 output.java
$ go run cmd/xgen/xgen.go -l Java -i test/xsd/base64.xsd -o output
done
$ ls -la | grep output
-rw-rw-r-- 1 bpursley bpursley 2066 Jul 20 10:06 output.java
$ go run cmd/xgen/xgen.go -l Java -i test/xsd/base64.xsd
done
$ ls -la | grep xgen_out
-rw-rw-r-- 1 bpursley bpursley 2066 Jul 20 10:06 xgen_out.java
PR Details
Fix directory creation and filename extension handling
Description
Fixes a bug where xgen assumes that the output path provided by the user is a directory. This removes the call to PrepareOutputDir from xgen.go, but this should be fine because PrepareOutputDir is also called, correctly, in parser.go.
Fixes a bug where the language-specific generator code assumes that the output path does not contain the file extension. This commit adds a helper function called FileWithExtension that checks to see if the extension already exists on the filename and does not add it again if it does.
Related Issue
Fixes #56
Motivation and Context
How Has This Been Tested
Unit tests and manual tests (see below).
Types of changes
Checklist