Add to Favorites    Make Home Page 1166 Online  
 Language Categories  
 Our Services  

Home » C Home » File Operations Home » File Splitting & Merging Utility

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title File Splitting & Merging Utility
Author Deepak Gupta
Author Email dgupta_2000 [at] rediffmail.com
Description Its a File Splitting & Merging Utility in 'C'.

Category C » File Operations
Hits 394539
Code Select and Copy the Code
Code: #include<stdio.h> #include<conio.h> #include<sys/stat.h> // Funtion prototype to split in Equal size void split_equal(char *fname,long int pieces); // Funtion prototype to split in size defined by the user void split_size(char *fname, long int sp_size); // Funtion prototype to merge the splitted file void merge(char *o_fname, long int no_file); /*Main Starts*/ void main() { int ch; long int size,pieces,sp_size,no_file; char *fname,*o_fname; FILE *fp; struct stat statbuff; // stat structure to get file size clrscr(); printf(" SPLITTING PROCESS......"); printf(" Enter the path of the file to be splitted : "); fflush(stdin); gets(fname); // Name of the File to be splitted fp=fopen(fname,"rb+"); if(fp==NULL) { printf(" "); fprintf(stderr,"Cannot Open the File."); getch(); exit(0); } stat(fname,&statbuff); size=statbuff.st_size; // Get the size of the file to splitted fclose(fp); printf(" The Size of the File is %ld bytes.",size); printf(" SELECT THE WAY IN WHICH TO SPLIT THE FILE : "); printf(" 1.) In Equal Numbers."); printf(" 2.) User Defined Sizes."); printf(" Enter your choice : "); scanf("%d",&ch); // Start case switch(ch) { case 1: printf(" Enter the Number of Pieces : "); scanf("%ld",&pieces); // Define the number of pieces in which file will be splitted if(pieces>size) { printf(" Invalid Number of pieces."); getch(); exit(0); } split_equal(fname,pieces); // Function call to split printf(" Files Successfully Splitted."); getch(); break; case 2: printf(" Enter the Size in which to split the files : "); scanf("%ld",&sp_size); // Define the size in which file will be splitted if(sp_size>size) { printf(" Invalid size of the pieces."); getch(); exit(0); } split_size(fname,sp_size); // Function call to split printf(" Files Successfully Splitted."); getch(); break; default: printf(" Invalid Choice."); getch(); exit(0); } // End Case printf(" A .bat file has been created, copy all the pieces "); printf(" and the .bat file to the desired destination and run "); printf(" the .bat file to get the merged file."); getch(); //The Merging Process /* printf(" Do You Want to Merge the Splitted Files (Y/N): "); fflush(stdin); ch=getchar(); if(toupper(ch)=='Y') { // Start The Merging Process clrscr(); printf(" MERGING PROCESS......."); printf(" Enter the Path and Name of the Merged Output File : "); fflush(stdin); gets(o_fname); // Get the name of Output file printf(" Enter the Number of Files which are to be Merged : "); scanf("%ld",&no_file); // Get the Number of splitted files to be merged merge(o_fname,no_file); // Function call for Merging the Files printf(" The Splitted Files have been successfully Merged."); getch(); } */ } // End Main // Start of function definition split_equal void split_equal(char *fname,long int pieces) { FILE *fp,*n_fp,*fp_bat; char ch,*p,q[50],t[50],z[50]; int i,j,k,x; char *n_fname,base[5]; long int size,f_size,offset; struct stat statbuff; stat(fname,&statbuff); size=statbuff.st_size; offset=size%pieces; f_size=(size-offset)/pieces; p=fname; printf(" The first %ld files will be of size %ld bytes each.",pieces-1,f_size); printf(" The %ldth file will be of size %ld bytes. ",pieces,f_size+offset); fp=fopen(fname,"rb+"); if(fp==NULL) { printf(" "); fprintf(stderr,"Cannot Open the File."); getch(); exit(0); } strrev(p); for(j=0;p[j]!='\';j++) //Extracting the Name of file in variable q { q[j]=p[j]; } q[j]='

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi �դ ?�� ��??���
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=925


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review