(1) calc_size.c source code
#include <stdio.h>
#include <windows.h>
#include <string.h>
int main(int argc, char** argv)
{
int size = 0, len;
FILE * fp = NULL;
char BufferFileName[MAX_PATH];
char *str_buf = NULL;
if (argc <=1)
{
printf("usage: cmd file .");
return -1;
}
GetModuleFileName(NULL,BufferFileName,MAX_PATH);
printf("file path: %s \n", BufferFileName);
len = strlen(BufferFileName);
printf("len = %d ", len);
str_buf = (BufferFileName + len - 13);//这里calc_size.exe
strcpy(str_buf, argv[1]);
printf("argv[1] = %s, file_path_argv[1] = %s ", argv[1], BufferFileName);
fp = fopen(BufferFileName, "r");
fseek(fp, 0L, SEEK_END);
size = ftell(fp);
fclose(fp);
printf("size = %d", size);
return size;
}
(2) 文件树结构:
D: - - - AUTOTEST - - - FPGA.bat
|
- - - - - - - - FPGA - - - - - T32 - - - -- - calc_size.exe
|
- - - - - - -- load_image_cmm - - - - hello.raw
(3) FPGA.bat code
echo off
set path=%path%;d:\AUTOTEST\FPGA\t32
calc_size.exe load_image_cmm\hello.raw
pause
放到其他E:盘等同理。