This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

how to determine number of open files

Other Parts Discussed in Thread: TMS320VC5505

hi all,

 

I'm using a TMS320Vc5505 eZdsp USB stick with Code Composer Version: 4.0.0.16000 

I've determined that the maximum number of open files allowed by the system (via stdio's fopen) is 10; you can use this code snippet to verify:

    printf("Max number of files: FOPEN_MAX=(%d)\n",FOPEN_MAX);

 

My question is:  is there any way to determine how many files are currently open?

 

thanks!

-Rob

 

  • There is no standard C RTS function you can call which tells you the number of currently open files.  There might be some very system specific not portable way to do it.  But I highly advise against any hack like that.

    Thanks and regards,

    -George

     

  • Thanks Georgem.  I'm aware that there's no platform-independent way to do this, but I was hoping somebody would have a hack just for my Code Composer setup--especially given its smaller-than-usual file limit.

     

  • You could modify the RTS source file fopen.c to add a function which iterates through the internal C I/O structure counting assigned FILE slots.  See _search_fp() in particular. 

    However, if you're willing to modify the RTS source, you would probably be better served just changing the definition of _NFILE in stdio.h and recompiling the RTS.

    Note that the reason there's no standard function is that it's of limited utility; it's easier to keep track of how many files you've opened, and add 3 for stdin, stdout, and stderr.

  • thanks, Archaeologist.  Useful advice.  It occurred to me that I could also "overload" fopen and fclose to count the number of times it opens and closes a file.

     

    I agree that it's easy enough to count how many files _I've_ personally opened, but I'm trying to gain visibility into how many files _everybody else_ have opened.

     

  • I wanted to start looking at the RTS source code files mentioned above, but I don't see the rts.src archive anywhere in my c:\Program Files\Texas Instruments installation (I have the CCSv4 installation which came with my C5505 EZDSP).   

    Did I miss an installation step?  Am I supposed to download it from elsewhere?

     

  • Ah, I found the source code in a zip file:

    C:\Program Files\Texas Instruments\ccsv4\tools\compiler\c5500\lib\rtssrc.zip