Subversion Repositories SvarDOS

Rev

Rev 503 | Rev 538 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 503 Rev 533
Line 159... Line 159...
159
  }
159
  }
160
  return(errcode);
160
  return(errcode);
161
}
161
}
162
 
162
 
163
 
163
 
164
static int cmd_copy(struct cmd_funcparam *p) {
164
static enum cmd_result cmd_copy(struct cmd_funcparam *p) {
165
  struct copy_setup *setup = (void *)(p->BUFFER);
165
  struct copy_setup *setup = (void *)(p->BUFFER);
166
  unsigned short i;
166
  unsigned short i;
167
  unsigned short copiedcount_in = 0, copiedcount_out = 0; /* number of input/output copied files */
167
  unsigned short copiedcount_in = 0, copiedcount_out = 0; /* number of input/output copied files */
168
  struct DTA *dta = (void *)0x80; /* use DTA at default location in PSP */
168
  struct DTA *dta = (void *)0x80; /* use DTA at default location in PSP */
169
 
169
 
Line 180... Line 180...
180
    outputnl("");
180
    outputnl("");
181
    outputnl("To append files, specify a single file for destination, but multiple files");
181
    outputnl("To append files, specify a single file for destination, but multiple files");
182
    outputnl("for source (using wildcards or file1+file2+file3 format).");
182
    outputnl("for source (using wildcards or file1+file2+file3 format).");
183
    outputnl("");
183
    outputnl("");
184
    outputnl("NOTE: /A and /B are no-ops (ignored), provided only for compatibility reasons.");
184
    outputnl("NOTE: /A and /B are no-ops (ignored), provided only for compatibility reasons.");
185
    return(-1);
185
    return(CMD_OK);
186
  }
186
  }
187
 
187
 
188
  /* parse cmdline and fill the setup struct accordingly */
188
  /* parse cmdline and fill the setup struct accordingly */
189
 
189
 
190
  memset(setup, 0, sizeof(*setup));
190
  memset(setup, 0, sizeof(*setup));
Line 205... Line 205...
205
        }
205
        }
206
      } else if (imatch(p->argv[i], "/v")) {
206
      } else if (imatch(p->argv[i], "/v")) {
207
        setup->verifyflag = 1;
207
        setup->verifyflag = 1;
208
      } else {
208
      } else {
209
        outputnl("Invalid switch");
209
        outputnl("Invalid switch");
210
        return(-1);
210
        return(CMD_FAIL);
211
      }
211
      }
212
      continue;
212
      continue;
213
    }
213
    }
214
 
214
 
215
    /* not a switch - must be either a source, a destination or a + */
215
    /* not a switch - must be either a source, a destination or a + */
216
    if (p->argv[i][0] == '+') {
216
    if (p->argv[i][0] == '+') {
217
      /* a plus cannot appear after destination or before first source */
217
      /* a plus cannot appear after destination or before first source */
218
      if ((setup->dst[0] != 0) || (setup->src_count == 0)) {
218
      if ((setup->dst[0] != 0) || (setup->src_count == 0)) {
219
        outputnl("Invalid syntax");
219
        outputnl("Invalid syntax");
220
        return(-1);
220
        return(CMD_FAIL);
221
      }
221
      }
222
      setup->lastitemwasplus = 1;
222
      setup->lastitemwasplus = 1;
223
      /* a plus may be immediately followed by a filename - if so, emulate
223
      /* a plus may be immediately followed by a filename - if so, emulate
224
       * a new argument */
224
       * a new argument */
225
      if (p->argv[i][1] != 0) {
225
      if (p->argv[i][1] != 0) {
Line 239... Line 239...
239
    }
239
    }
240
 
240
 
241
    /* must be a dst then */
241
    /* must be a dst then */
242
    if (setup->dst[0] != 0) {
242
    if (setup->dst[0] != 0) {
243
      outputnl("Invalid syntax");
243
      outputnl("Invalid syntax");
244
      return(-1);
244
      return(CMD_FAIL);
245
    }
245
    }
246
    if (file_truename(p->argv[i], setup->dst) != 0) {
246
    if (file_truename(p->argv[i], setup->dst) != 0) {
247
      outputnl("Invalid destination");
247
      outputnl("Invalid destination");
248
      return(-1);
248
      return(CMD_FAIL);
249
    }
249
    }
250
    setup->dst_asciimode = setup->last_asciimode;
250
    setup->dst_asciimode = setup->last_asciimode;
251
    /* if dst is a directory then append a backslash */
251
    /* if dst is a directory then append a backslash */
252
    setup->dstlen = path_appendbkslash_if_dir(setup->dst);
252
    setup->dstlen = path_appendbkslash_if_dir(setup->dst);
253
  }
253
  }
Line 265... Line 265...
265
  #endif
265
  #endif
266
 
266
 
267
  /* must have at least one source */
267
  /* must have at least one source */
268
  if (setup->src_count == 0) {
268
  if (setup->src_count == 0) {
269
    outputnl("Required parameter missing");
269
    outputnl("Required parameter missing");
270
    return(-1);
270
    return(CMD_FAIL);
271
  }
271
  }
272
 
272
 
273
  /* perform the operation based on setup directives:
273
  /* perform the operation based on setup directives:
274
   * iterate over every source and copy it to dest */
274
   * iterate over every source and copy it to dest */
275
 
275
 
Line 346... Line 346...
346
      outputnl(setup->dst);
346
      outputnl(setup->dst);
347
 
347
 
348
      t = cmd_copy_internal(setup->dst, 0, setup->cursrc, 0, appendflag, setup->databuf, setup->databufsz);
348
      t = cmd_copy_internal(setup->dst, 0, setup->cursrc, 0, appendflag, setup->databuf, setup->databufsz);
349
      if (t != 0) {
349
      if (t != 0) {
350
        outputnl(doserr(t));
350
        outputnl(doserr(t));
351
        return(-1);
351
        return(CMD_FAIL);
352
      }
352
      }
353
 
353
 
354
      copiedcount_in++;
354
      copiedcount_in++;
355
    } while (findnext(dta) == 0);
355
    } while (findnext(dta) == 0);
356
 
356
 
357
  }
357
  }
358
 
358
 
359
  sprintf(setup->databuf, "%u file(s) copied", copiedcount_out);
359
  sprintf(setup->databuf, "%u file(s) copied", copiedcount_out);
360
  outputnl(setup->databuf);
360
  outputnl(setup->databuf);
361
 
361
 
362
  return(-1);
362
  return(CMD_OK);
363
}
363
}