File Naming

C

chiku

Hi,
My application require saving data from 3 diff sources into 3
different files at time. I want each of my file to be named like
[Hw_Id][Src_Id][Trip_Id][Seg_Id] where Hw_Id is my hardware in use,
Src_Id is data source(one of the 3),Trip_Id is this trip number when
i am capturing datas from 3 diff source(this system restart),Seg_Id is
this this set of 3 data files.

I need this unique naming because i want to analyse each file after
each trip and want to delete old files once memory is full.

Any help will be appreciated?

Chiku
 
F

Fred Zwarts

chiku said:
Hi,
My application require saving data from 3 diff sources into 3
different files at time. I want each of my file to be named like
[Hw_Id][Src_Id][Trip_Id][Seg_Id] where Hw_Id is my hardware in use,
Src_Id is data source(one of the 3),Trip_Id is this trip number when
i am capturing datas from 3 diff source(this system restart),Seg_Id is
this this set of 3 data files.

I need this unique naming because i want to analyse each file after
each trip and want to delete old files once memory is full.

Any help will be appreciated?

The naming of files is not really a C++ topic.
Consult the documentation of your operating system to see what file names are allowed.
If you need a portable solution, check also the limitations of other operating systems.
There are operating system which do not allow square brackets in file names.
Other, mostly older, operating systems restrict file names to 8 characters,
which is probably not a concern any more nowadays.
 
J

James Kanze

messagenews:f12a1bc5-163b-40f9-895a-c85dba065243@o36g2000vbi.googlegroups..com...
My application require saving data from 3 diff sources into
3 different files at time. I want each of my file to be
named like [Hw_Id][Src_Id][Trip_Id][Seg_Id] where Hw_Id is
my hardware in use, Src_Id is data source(one of the
3),Trip_Id is this trip number when i am capturing datas
from 3 diff source(this system restart),Seg_Id is this this
set of 3 data files.
I need this unique naming because i want to analyse each
file after each trip and want to delete old files once
memory is full.
Any help will be appreciated?
The naming of files is not really a C++ topic.
Consult the documentation of your operating system to see what
file names are allowed. If you need a portable solution,
check also the limitations of other operating systems. There
are operating system which do not allow square brackets in
file names.

And they may be discouraged even on systems which allow them.
Unix allows everything but '/' and '\0', but practical
considerations mean that it's generally better to avoid shell
meta-characters (including whitespace).
Other, mostly older, operating systems restrict file names to
8 characters, which is probably not a concern any more
nowadays.

At least on system only allowed 6 plus 3, with no case
distinction, and almost no punctuation (other than the '.' which
separated the 6 from the 3). For absolute portability, you
should probably limit yourself to [A-Z0-9]{1-6}\.[A-Z0-9]. In
practice, however, such restrictions probably aren't very
relevant today, and [A-Za-z0-9_-.]+, with some "reasonable"
maximum length, is probably pretty safe (although you might want
to pay attention with how you use the '.'---some systems treat
the part of the name following the last '.' specially). And
although you can use both capitals and small letters, you should
avoid names that differ only in case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,417
Latest member
DarrenGaun

Latest Threads

Top