3 // make ms be quiet about strncat.
4 #define _CRT_SECURE_NO_WARNINGS
15 // turns the cygwin name format into a usable windos filename.
16 char *translate_cygwin(char *fname)
18 int oldlen = strlen(fname);
19 if (!strncmp(fname, "/cygdrive/", 10) && (oldlen > 10) ) {
20 // in the first case the filename has /cygdrive in it, right at the front.
21 char *newprefix = (char *)malloc(oldlen);
22 // build the drive letter first.
23 newprefix[0] = fname[10];
26 // concatenate the filename without cygdrive in it.
27 strncat(newprefix, fname + 11, oldlen - 11 + 1); // one extra for null char.
28 return newprefix; // mem leak here; cannot be helped for quick fix using functional style.
29 } else if ( (fname[0] == '-') && (oldlen > 12)
30 && (!strncmp(fname + 2, "/cygdrive/", 10)) ) {
31 // in the second case we are looking for command line options. this code handles a parameter
32 // that starts with a single dash and has a single flag character after that.
33 char *newprefix = (char *)malloc(oldlen);
34 newprefix[0] = fname[0];
35 newprefix[1] = fname[1];
36 newprefix[2] = fname[12];
39 // now concatenate the useful filename portion, offset by the flag found.
40 strncat(newprefix, fname + 13, oldlen - 13 + 1); // one extra for null char.
50 function dossify_and_run_commands()
54 declare -a darc_commands=()
56 // we only mess with the command line on windows.
57 if [ "$OS" == "Windows_NT" ]; then
58 if [[ "$i" =~ ^-[a-zA-z][/\"].* ]]; then
59 #echo matched on our pattern for parameters
61 filename="$(unix_to_dos_path ${i:2})"
63 #echo "first two chars are $flag"
64 #echo "last after that are $filename"
65 #combined="$flag$filename"
66 #echo combined is $combined
68 darc_commands+=("$flag$filename")
70 darc_commands+=($(unix_to_dos_path $i))
81 int main(int argc, char *argv[])
83 for (int i = 1; i < argc; i++) {
84 printf("%s", translate_cygwin(argv[i]));