LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-05-2016, 11:55 AM   #1
krapykreme
LQ Newbie
 
Registered: Feb 2016
Posts: 8

Rep: Reputation: Disabled
Copying the name of the next file in a directory to fname.


Hello! I am working on an assignment involving the creation of a simple file system. For one of the methods, I have to make is getnextfilename.What this basically does is that it copies the name of the next file in the directory into fname and returns non-zero if there is a new file.Once all of the files have been returned, it returns a zero.

This is what I have done, but I am not sure it is right.
Code:
int sfs_getnextfilename(char *fname){

	int i;
	int filenameindex = 1;

	for (i = 0; i < MAXFILE; i++ ){ 
		strncpy(fname, filename, 16);
		if(fname != filename){
			return 1;
		}
		filenameindex++;
	}
	return 0;
}
I am very new to C, so please be considerate. Thank you for your help.
 
Old 04-05-2016, 02:11 PM   #2
ilesterg
Member
 
Registered: Jul 2012
Distribution: CentOS, SLES, RHEL, HP-UX, OpenSUSE Tumbleweed KDE
Posts: 505

Rep: Reputation: 54
What exactly is the problem? Where's your question? In the first place, what does the code have to do with Linux? It appears as a C program which practically runs on any platform.
 
Old 04-07-2016, 08:36 PM   #3
krapykreme
LQ Newbie
 
Registered: Feb 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
It is a supposed to be part of a mountable disk file system that run on Linux. I am not sure if this is supposed to be the right way to go about it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
resuming file copying after remounting CIFS directory a1337q Linux - General 2 03-14-2011 02:33 PM
copying the .rhosts file to a remote directory kaplan71 Linux - General 1 01-24-2008 06:43 PM
Copying a single file into each directory of a directory tree mlapl1 Linux - Newbie 2 06-27-2007 11:18 PM
Copying a file into a directory Nizhni Linux - Newbie 3 01-24-2005 01:47 AM
Copying the newest file in a directory to another location Transition Linux - General 2 01-14-2005 12:53 PM


All times are GMT -5. The time now is 05:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration