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

Home » C Home » File Operations Home » Menu Driven File Attribute Changing Utility

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

Search Projects & Source Codes:

Title Menu Driven File Attribute Changing Utility
Author Harshvir Singh Sidhu
Author Email hvssidhu [at] yahoo.com
Description This is an C program, that provides DOS based menus for changing the attributes of the files. It provides a menu with options of selecting file, viewing current attributes, and changing attributes.
Category C » File Operations
Hits 384083
Code Select and Copy the Code
#include<stdio.h> #include<conio.h> #include<dos.h> #define SE 112 #define US 7 int get_file_attrib(char fname[40]); void setfattr(void); void setattr(int,int,int); char fname[40]; char far *scr; char far *mode1; FILE *fp; int mode=0; int r,c,i,j,b,attrib,flen=1; int v=0; char ch,t; void main() { _AH=0; _AL=3; geninterrupt(0x10); if((*mode1 &0x30)== 0x30) scr=(char far*) 0xb0000000; else scr=(char far*) 0xb8000000; begin: r=4; c=20; clrscr(); gotoxy(21,5); printf("1. Select a File."); gotoxy(21,6); printf("2. View Attributes."); gotoxy(21,7); printf("3. Set Attributes."); gotoxy(21,8); printf("4. Remove Attributes."); gotoxy(21,9); printf("5. Exit."); gotoxy(21,11); printf("Enter Choice: [1]"); while(ch!=13) { for(i=4;i<11;i++) setattr(i,20,US); setattr(r,c,SE); gotoxy(36,11); ch=getch(); if(ch=='H'||ch=='h') { if(r==4) r=4; else r--; } else if(ch=='P'||ch=='p') { if(r==8) r=8; else r++; } else if(ch=='1') { r=4; } else if(ch=='2') { r=5; } else if(ch=='3') { r=6; } else if(ch=='4') { r=7; } else if(ch=='5') { r=8; } t=r+48-3; printf("%c",t); gotoxy(36,13); } ch=' '; b=r-3; clrscr(); switch(b) { case 1: strcpy(fname,NULL); flen=0; printf("Please Enter Valid Filename with Extension: "); scanf("%[^ ]s",fname); attrib = get_file_attrib(fname); if(attrib & FA_LABEL) { flen=2; } if(attrib & FA_DIREC) { flen=2; } if(flen!=2) { fp=fopen(fname,"rb"); if(fp==NULL) { printf("NON_EXISTING FILE "); flen=1; getch(); } fclose(fp); } v=strlen(fname); for(i=0;i<v;i++) { fname[i]=tolower(fname[i]); } break; case 2: if(flen==1) { printf("No Valid Filename Entered."); getch(); goto endl; } v=0; printf("%s is",fname); attrib = get_file_attrib(fname); if(attrib & FA_RDONLY) { printf(" Read-only file"); v=1; } if(attrib & FA_HIDDEN) { printf(" Hidden file"); v=1; } if(attrib & FA_SYSTEM) { printf(" System file"); v=1; } if(attrib & FA_LABEL) { printf(" Volume label"); v=1; } if(attrib & FA_DIREC) { printf(" Directory"); v=1; } if(attrib & FA_ARCH) { printf(" Archive file"); v=1; } printf("."); if(v==1) getch(); endl: v=0; break; case 3: if(flen==1) { printf("No Valid Filename Entered."); getch(); goto endl1; } mode=1; setfattr(); endl1: break; case 4: if(flen==1) { printf("No Valid Filename Entered."); getch(); goto endl2; } mode=2; setfattr(); endl2: break; case 5: goto end; } goto begin; end: clrscr(); } void setattr(int row,int col,int attr) { int i; for(i=0;i<23;i++) { *(scr+row*160+col*2+1)=attr; col++; } } int get_file_attrib(char fname[40]) { return(_chmod(fname,0)); } void setfattr() { begin1: r=4; c=20; clrscr(); gotoxy(21,5); printf("1. Read Only."); gotoxy(21,6); printf("2. Hidden."); gotoxy(21,7); printf("3. System."); gotoxy(21,8); printf("4. Archive."); gotoxy(21,9); printf("5. Back."); gotoxy(21,11); printf("Enter Choice: [1]"); while(ch!=13) { for(i=4;i<11;i++) setattr(i,20,US); setattr(r,c,SE); gotoxy(36,11); ch=getch(); if(ch=='H'||ch=='h') { if(r==4) r=4; else r--; } else if(ch=='P'||ch=='p') { if(r==8) r=8; else r++; } else if(ch=='1') { r=4; } else if(ch=='2') { r=5; } else if(ch=='3') { r=6; } else if(ch=='4') { r=7; } else if(ch=='5') { r=8; } t=r+48-3; printf("%c",t); gotoxy(36,13); } ch=' '; b=r-3; clrscr(); attrib=get_file_attrib(fname); if(mode==1) { switch(b) { case 1: _chmod(fname,1,attrib|FA_RDONLY); break; case 2: _chmod(fname,1,attrib|FA_HIDDEN); break; case 3: _chmod(fname,1,attrib|FA_SYSTEM); break; case 4: _chmod(fname,1,attrib|FA_ARCH); break; case 5: goto end1; } } if(mode==2) { switch(b) { case 1: v=~FA_RDONLY; attrib=attrib&v; _chmod(fname,1,attrib); break; case 2: v=~FA_HIDDEN; attrib=attrib&v; _chmod(fname,1,attrib); break; case 3: v=~FA_SYSTEM; attrib=attrib&v; _chmod(fname,1,attrib); break; case 4: v=~FA_ARCH; attrib=attrib&v; _chmod(fname,1,attrib); break; case 5: goto end1; } } v=0; goto begin1; end1: clrscr(); mode=0; }

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=626


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