[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

problems with stat on darwin

Asked by ctangent in C Programming Language

Tags: getfilesize, darwin, linux, stat

I am using "struct stat file_stat" in order to retriev information about a file (namely the filesize).  When I run a simple program that just gets the file size of a file and prints out the filesize, it works on Solaris workstations, and on a P4 cluster running linux.  However, when it is running on an Apple G5 cluster running Darwin, Mac OS X 10.4, the program fails (the function stat() returns -1).

I also had problems compiling a program that explicitly declared a type off_t, which compiled on the other systems, but on the G5 cluster it failed and claimed that it did not understand off_t.  I am assuming that these problems are related.

Does anyone here have experience with working with C on Darwin, and if so, do you have any idea what could cause this problem?  Thank you for your help.


My program is below:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define TRUE 0
#define FALSE 1

unsigned long long getFileSize(char filename[]);

int main(int argc, char **argv)
{
      unsigned long long head, seq, size, tot;
      unsigned long long bufferSize = 1000000;
      
      char * filename = "yeast.fsa\0";
      printf("Reading in file:%s\n",filename);

      //      read fasta calls
      size = getFileSize(filename);
      
      printf("file size: %lld\n",size);
      
      return 0;
}


unsigned long long getFileSize(char filename[]){
      static unsigned long long size = 0;
      static short int fileSizeSet = FALSE;
      
      struct stat file_stat;
      int error;
      // only set the filesize once, then just
      // keep this value in memory, and use
      // "GET FILE SIZE" to get it!
      if(fileSizeSet == FALSE){
            error = stat(filename, &file_stat);
            
            if(error == -1){
                  return 0;      
            }
            else{
                  size = (unsigned long long)file_stat.st_size;
                  fileSizeSet = TRUE;
            }
      }
      
      return size;
}
[+][-]10/28/05 02:55 PM, ID: 15182924Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/05 03:00 PM, ID: 15182939Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/05 03:06 PM, ID: 15182963Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/05 03:08 PM, ID: 15182968Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/05 03:08 PM, ID: 15182970Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/05 03:10 PM, ID: 15182975Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C Programming Language
Tags: getfilesize, darwin, linux, stat
Sign Up Now!
Solution Provided By: cwwkie
Participating Experts: 3
Solution Grade: A
 
[+][-]10/28/05 03:10 PM, ID: 15182978Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/05 03:12 PM, ID: 15182982Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/28/05 03:16 PM, ID: 15183003Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/05 03:17 PM, ID: 15183007Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/28/05 03:26 PM, ID: 15183059Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/29/05 04:29 PM, ID: 15186463Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/30/05 06:20 AM, ID: 15187994Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89