Sponsored Content
Top Forums Programming Copying a file and reading size I get always zero. Post 302985521 by clxspain on Thursday 10th of November 2016 06:46:48 PM
Old 11-10-2016
Copying a file and reading size I get always zero.

I need to copy a file (srcFile) to a new ubication (destFile). Then I calculate the size of the copy file using stat. The problem is that I always get a cero size value although the file has not cero size in the hard disk.

The source code that does this is :

PROGRAM 1:

Code:
  char srcFile[MAX_FILE_SIZE];
  char destFile[MAX_FILE_SIZE];
  int fileDest = 0;

  strcpy(srcFile, "/dir1/file1.bin");
  strcpy(destFile, "/dir2/newfile1.bin");

  int rf = 255;
         
  if (rf = rename(srcFile, destFile)) 
  {
    // Process error
  }

  struct stat dest_info;
  int sr = stat(destFile, &dest_info);
        
  printf("New file size is %d", dest_info.st_size);

Please, can you help me to solve this issue? Thanks in advance.

Last edited by Scrutinizer; 11-10-2016 at 08:37 PM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Strange difference in file size when copying LARGE file..

Hi, Im trying to take a database backup. one of the files is 26 GB. I am using cp -pr to create a backup copy of the database. after the copying is complete, if i do du -hrs on the folders i saw a difference of 2GB. The weird fact is that the BACKUP folder was 2 GB more than the original one! ... (1 Reply)
Discussion started by: 0ktalmagik
1 Replies

2. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

3. Shell Programming and Scripting

URGENT HELP NEEDED ON -File size reading

All Expert, I am using Sun OS 5.8 and Perl version 5 in One server and Perl 5.8 in another unix server. I am able to read a file using fopen function of perl --file size having more then 3 GB of data.(In the machine where Perl 5.8 install) But when i am running the same perl script --It... (1 Reply)
Discussion started by: jambesh
1 Replies

4. Programming

Reading a whole line without betting on size

i have been googling, and came to the conclusion that there is not standard C library (or commonly used) that reads a complete line of a file, without a size parameter being involved. so, as a little exercise i decided to think it over, and make my own i came up with an idea, and wanted to... (2 Replies)
Discussion started by: broli
2 Replies

5. Solaris

Directory size larger than file system size?

Hi, We currently have an Oracle database running and it is creating lots of processes in the /proc directory that are 1000M in size. The size of the /proc directory is now reading 26T. How can this be if the root file system is only 13GB? I have seen this before we an Oracle temp file... (6 Replies)
Discussion started by: sparcman
6 Replies

6. Shell Programming and Scripting

The scripts not able to make the file to size 0, every times it go back to its original size

#!/bin/sh ########################################################################################################## #This script is being used for AOK application for cleaning up the .out files and zip it under logs directory. # IBM # Created #For pdocap201/pdoca202 .out files for AOK #1.... (0 Replies)
Discussion started by: mridul10_crj
0 Replies

7. Shell Programming and Scripting

Script to read file size and send email only if size > 0.

Hi Experts, I have a script like $ORACLE_HOME/bin/sqlplus username/password # << ENDSQL set pagesize 0 trim on feedback off verify off echo off newp none timing off set serveroutput on set heading off spool Schemaerrtmp.txt select ' TIMESTAMP COMPUTER NAME ... (5 Replies)
Discussion started by: welldone
5 Replies

8. Programming

[c] How to calculate size of the file from size of the buffer?

Hi, Can I find size of the file from size of the buffer written? nbECRITS = fwrite(strstr(data->buffer, ";") + 1, sizeof(char), (data->buffsize) - LEN_NOM_FIC, fic_sortie); Thank You :) (1 Reply)
Discussion started by: ezee
1 Replies

9. UNIX for Dummies Questions & Answers

Ls directory size reporting byte size instead of file count

I have been searching both on Unix.com and Google and have not been able to find the answer to my question. I think it is partly because I can't come up with the right search terms. Recently, my virtual server switched storage devices and I think the problem may be related to that change.... (2 Replies)
Discussion started by: jmgibby
2 Replies

10. UNIX for Beginners Questions & Answers

Reading and copying a selected rows

Dear All, I have a data file input.res like below. (Only six column shown here for example.) Sequence of first column starting from 1 to 148. Input file 1 Q0 9_August_2014_Entertainment2 0 20.14967806339729 BM25b1.0 1 Q0 13_October_2012_Page323 1 20.134224346765738 BM25b1.0 1 Q0... (2 Replies)
Discussion started by: imranrasheedamu
2 Replies
atbindrule(3)						       AtFS Toolkit Library						     atbindrule(3)

NAME
atBindAddRule, atBindDelRule, atBindRuleFile, atBindDisplayErrors, atBindTestRule, atBindShowRules, atBindListRules - version bind rule handling SYNOPSIS
#include <atfs.h> #include <atfstk.h> int atBindAddRule (char *ruleName, char *ruleBody, char *srcFile, int srcLine); int atBindDelRule (char *ruleName); int atBindRuleFile (char *fileName); int atBindDisplayErrors; int atBindTestRule (char *ruleName); int atBindShowRules (void); char**atBindListRules (void); DESCRIPTION
The atBind module maintains an internal database storing all known version bind rules. The atBindAddRule function stores a new rule in the internal database. It expects the rule name, optionally including parameter defini- tions, and the rule body as string arguments. Additionally, the filename (srcFile) of the file, where the rule is read from, and the line within that file (srcLine), may be given. This is used for producing proper error messages. atBindAddRule returns -1 on error, 0 otherwise. atBindDelRule removes a previously defined rule from the internal database. It returns a negative return value (-1), when no rule with the given name was not found in the internal database. The atBindRuleFile function scans a file containing version bind rules and adds all contained rules to the internal database. It returns the number of version bind rules successfully added to the internal database. A zero return value may also indicate an error. The switch atBindDisplayErrors may be set TRUE to enable error reporting during parsing of version binding rules. Error messages will be written directly to standard error. Initially, atBindDisplayErrors is set FALSE. AtBindTestRule reports whether ruleName is defined as version binding rule or not. It returns a non zero (TRUE) value when the name is defined, otherwise FALSE. atBindShowRules dumps the internal database to the standard output. Return value is always TRUE. atBindListRules returns all known bind rule names in a list. The list memory is allocated by use of malloc(3). On error, atBindListRules returns a null pointer. DIAGNOSTICS
Upon error, each routine returns a null value, the variable atBindError is set true (non-zero), and an explaining message is copied to the atBindErrorMsg string buffer. The atBindError variable is cleared upon successful calls, the message buffer remains unchanged. ENVIRONMENT
SHAPETOOLS - list of path names as search space for files containing version bind rules. The bind rule files must be named BindRules. Default path is /usr/local/lib/shape. FILES
$SHAPETOOLS/BindRules SEE ALSO
atbind(3) AtFStk-1.12 Tue Jun 29 16:16:26 1993 atbindrule(3)
All times are GMT -4. The time now is 10:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy