-
Notifications
You must be signed in to change notification settings - Fork 2
/
autoExt.c
37 lines (33 loc) · 1.02 KB
/
autoExt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<stdio.h>
#include<conio.h>
#include<string.h>
void manuExt(char *enFileName);
int getExt(char fileName[],char ext[]);
int fileWrite(char *inFileName,char *outFileName,unsigned char key);
void autoExt(char *enFileName)
{
char choice,fext[6],deFileName[100];
int i,err;
printf("\nDetecting key and extension...");
i=getExt(enFileName,fext);
if(i<0)
{
printf("\n\aAutomatic Detection Failed.\nTry Manual Method instead?\n\tY=Yes\n\tAnyKey=No");
choice=getch();
if(choice=='y' || choice=='Y')
manuExt(enFileName);
}
else
{
printf("\nDetected File Extension: %s\nKEY: %d\n",fext,i);
printf("Enter New File Name to save: ");
gets(deFileName);
strcat(deFileName,fext);
printf("\nMaking File...");
err=fileWrite(enFileName,deFileName,(unsigned char)i);
if(err)
printf("\a\nOperation Failed.");
else
printf("\nOperation Complete.");
}
}