Note that there are some explanatory texts on larger screens.

plurals
  1. POAccepting a wildcard to open a file
    primarykey
    data
    text
    <p>OK this is embarrassing and as much as I hate to, I have no other option. I don't know C but I was presented with a problem that I need to solve and although I've done some researching the time it would take me to modify the program myself is just too much so I have to swallow my pride (and I'm guessing some rep pts) to ask for help.</p> <p>This is a simple program to convert a unix file to dos, the only problem is that I need it to accept wildcards (eg.. c:/>unix2dos *.txt or file*.txt ) Nothing fancy.</p> <p>Here is the code that I have now..</p> <pre><code> // UNIX2DOS - a Win32 utility to convert single text files from Unix to MS-DOS format. #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;io.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/stat.h&gt; #include &lt;sys/utime.h&gt; #ifndef TRUE # define TRUE (1) # define FALSE (0) #endif #define R_CNTRL "rb" #define W_CNTRL "wb" struct stat s_buf; int u2dos (path) char *path; { FILE *in, *out; int ch, prev_ch= 0, rval = FALSE; char temppath [16]; struct _utimbuf ut_buf; strcpy (temppath, "./clntmp"); strcat (temppath, "XXXXXX"); mktemp (temppath); if ((in=fopen (path, R_CNTRL)) == (FILE *) 0) return TRUE; if ((out=fopen (temppath, W_CNTRL)) == (FILE *) 0) { fclose (in); return TRUE; } #define LF 0x0A #define CR 0x0D while ((ch = getc (in)) != EOF) { if ( ( ch == LF) &amp;&amp; ( prev_ch != CR) &amp;&amp; ( putc( CR, out) == EOF) || ( putc( ch, out) == EOF) ) { rval = TRUE; break; } prev_ch= ch ; } if (fclose (in) == EOF) { rval = TRUE; } if (fclose (out) == EOF) { rval = TRUE; } ut_buf.actime = s_buf.st_atime; ut_buf.modtime = s_buf.st_mtime; if (_utime (temppath, &amp;ut_buf) == -1) rval = TRUE; if (unlink (path) == -1) rval = TRUE; if (rval) { unlink (temppath); return TRUE; } if (rename (temppath,path) == -1) { fprintf (stderr, "Unix2Dos: Problems renaming '%s' to '%s'.\n", temppath, path); fprintf (stderr, " However, file '%s' remains.\n", temppath); exit (1); } unlink (temppath); return FALSE; } void main (argc, argv) int argc; char **argv; { char *path; while (--argc&gt;0) { if (stat (path=*++argv, &amp;s_buf) != -1) { printf ("Unix2Dos: Processing file %s ...\n", path); if (u2dos (path)) { fprintf (stderr, "Unix2Dos: Problems processing file %s.\n", path); exit (1); } } else { fprintf (stderr, "Unix2Dos: Can't stat '%s'.\n", path); exit (1); } } } </code></pre> <p>I cant believe I have digressed to one of the "Send me da codez" people I have grown to despise but right now it seems like this is my best option.</p> <p>I'm going to go burry my head in the sand now. Thanks for your time.</p> <p><strong>EDIT</strong> </p> <p>Although implied, I thought I should make the question obvious. Can you please provide some assistance in modifying this program to accept wildcard variables in a windows environment?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload