Sponsored Content
Top Forums Programming How to read and write directory or file contents in c++ ? Post 302138073 by netwalker on Friday 28th of September 2007 01:29:27 PM
Old 09-28-2007
I recommend you to look at code of ls.
It is open source. If you are using open soure OS, source of ls should come in the distributive.

Anyway there is good explanation and links to source: ls - Wikipedia, the free encyclopedia

Understanding ls is very good way to start doing what you want.

About file contents, there are good functions for that, for example fopen.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove spaces from first field, and write entire contents into other text file

Hi all, I have searched and found various threads about removing spaces from a field within a text file. Unfortunately, I have not found exactly what I'm looking for, nor am I adept enough to modify what I've found into what I need. I use the following command to remove the first line... (3 Replies)
Discussion started by: carriehoff
3 Replies

2. UNIX for Dummies Questions & Answers

About read,write & execute permissons of a directory

Hi all, I want to know differences between read,write & execute permissons given to directory. Thanx in advance. (6 Replies)
Discussion started by: vishwasrao
6 Replies

3. Shell Programming and Scripting

Read contents from a file

Hi Friends, I am new to this forum. Just struck up with a logic. I have a csv file seperated by ":" (colons). This csv file contains hostname and groups as follows: HOSTNAME:VT Group SGSGCT2AVPX001:Team1 SGSGCT2AVPX003:Team2 SGSGCT2AVPX005:Team2 PHMNCTTAVPX001:Team3 I want to... (2 Replies)
Discussion started by: dbashyam
2 Replies

4. Solaris

add a ftp user with read and write permissions on a directory

hi all how I can create an ftp user in solaris 10 and have read and write permission on a directory. Thanks. (1 Reply)
Discussion started by: luisfja
1 Replies

5. Shell Programming and Scripting

how to read contents of file?

I have made a script something like this. I want it to read the contents of either file or directory but 'cat' and 'ls' is not working. Can anyone help me? I am a newbie in scripting so dont know much about it. I also dont know how can i put my code separatly on this forum #!/bin/bash echo... (9 Replies)
Discussion started by: nishrestha
9 Replies

6. Shell Programming and Scripting

Write array contents to file

Hi, I have a bash script that currently holds some data. I am trying to write all the contents to a file called temp.txt. I am using echo ${array} > temp.txt The problem that I am experiencing is that the elements are being written horizontally in the file. I want them written... (5 Replies)
Discussion started by: Filter500
5 Replies

7. Shell Programming and Scripting

Replace partial contents of file with contents read from other file

Hi, I am facing issue while reading data from a file in UNIX. my requirement is to compare two files and for the text pattern matching in the 1st file, replace the contents in second file by the contents of first file from start to the end and write the contents to thrid file. i am able to... (2 Replies)
Discussion started by: seeki
2 Replies

8. UNIX for Dummies Questions & Answers

Write terminal contents into a one file in UNIX

Hi guys, How to write terminal contents into a file in Unix operating system Actually I created GUI by using Gtk2-perl. I want to display data on GUI whatever the contents writing on terminal. So which command I have to use and where that command to be run I mean in shell script or Perl... (2 Replies)
Discussion started by: kiran425
2 Replies

9. UNIX for Dummies Questions & Answers

Trying To Write File Contents To Specfic .csv Cell

Hi, I'm attempting to write the entire contents of a file to a specific .csv cell. So far have only a nawk one liner that will write a value into a specific .csv cell. Trying to use man page but can't seem to get any farther. Any help would be appreciated. nawk -v r=2 -v c=3 -v val=5 -F,... (7 Replies)
Discussion started by: jimmyf
7 Replies

10. UNIX for Beginners Questions & Answers

Checking if the directory has read and write permission

logMsg='Started by '${USER} LOG_MESSAGE "${logMsg}" resultCode=$? if ]; then return ${resultCode} fi touch ${FILELISTPATH} resultCode=$? if ]; then logMsg='failed to create file list:'${FILELISTPATH} LOG_ERROR "${logMsg}" CUSTOM_PREPROCESS ${FATAL} ... (2 Replies)
Discussion started by: raka123
2 Replies
TIFFWriteDirectory(3T)													    TIFFWriteDirectory(3T)

NAME
TIFFWriteDirectory, TIFFRewriteDirectory - write the current directory in an open TIFF file SYNOPSIS
#include <tiffio.h> int TIFFWriteDirectory(TIFF* tif) int TIFFRewriteDirectory(TIFF* tif) DESCRIPTION
TIFFWriteDirectory will write the contents of the current directory to the file and setup to create a new subfile in the same file. Appli- cations only need to call TIFFWriteDirectory when writing multiple subfiles to a single TIFF file. TIFFWriteDirectory is automatically called by TIFFClose and TIFFFlush to write a modified directory if the file is open for writing. The TIFFRewriteDirectory function operates similarly to TIFFWriteDirectory but can be called with directories previously read or written that already have an established location in the file. It will rewrite the directory, but instead of place it at it's old location (as TIFFWriteDirectory would) it will place them at the end of the file, correcting the pointer from the preceeding directory or file header to point to it's new location. This is particularly important in cases where the size of the directory and pointed to data has grown, so it won't fit in the space available at the old location. RETURN VALUES
1 is returned when the contents are successfully written to the file. Otherwise, 0 is returned if an error was encountered when writing the directory contents. DIAGNOSTICS
All error messages are directed to the TIFFError(3T) routine. Error post-encoding before directory write. Before writing the contents of the current directory, any pending data are flushed. This mes- sage indicates that an error occurred while doing this. Error flushing data before directory write. Before writing the contents of the current directory, any pending data are flushed. This mes- sage indicates that an error occurred while doing this. Cannot write directory, out of space. There was not enough space to allocate a temporary area for the directory that was to be written. Error writing directory count. A write error occurred when writing the count of fields in the directory. Error writing directory contents. A write error occurred when writing the directory fields. Error writing directory link. A write error occurred when writing the link to the next directory. Error writing data for field "%s". A write error occurred when writing indirect data for the specified field. Error writing TIFF header. A write error occurred when re-writing header at the front of the file. Error fetching directory count. A read error occurred when fetching the directory count field for a previous directory. This can occur when setting up a link to the directory that is being written. Error fetching directory link. A read error occurred when fetching the directory link field for a previous directory. This can occur when setting up a link to the directory that is being written. SEE ALSO
libtiff(3T), TIFFOpen(3T), TIFFError(3T), TIFFReadDirectory(3T), TIFFSetDirectory(3T) September 26, 2001 TIFFWriteDirectory(3T)
All times are GMT -4. The time now is 06:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy