-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddAsset.c
More file actions
25 lines (23 loc) · 898 Bytes
/
addAsset.c
File metadata and controls
25 lines (23 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int addAsset(assetEntry* temp)
{
if( checkAssetExists(temp->assetId) )
return -2;
FILE* fp = NULL;
int count = 0;
char path[200]= "/home/navin/linux/assignment/29aug/miniproj/asset/";
strcat(path,temp->assetId);
printf("the filename is %s \n",path);
fp = fopen(path,"wb"); // open the file
if( fwrite(temp,sizeof(*temp),1,fp) == 1 )
{
printf("Asset added successfully \n");
fclose(fp);
return 0;
}
else{
printf(" error writting data \n");
if(fclose(fp)) // close the file
printf("Error closing the file\n");
return -1;
}
}