Re: identify the file type

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Mon, 23 May 2011 15:55:07 +0200


Hi,

In that case use e.g.

std::ifstream in("xmlorascii.txt");
TString xmlpreamble;
xmlpreamble.ReadLine(in);
bool isXML = xmlpreamble.BeginsWith("<?xml");

Of course you'll have to add some error handling (is the ifstream valid? etc)

Cheers, Axel.

On 5/23/11 12:05 PM, Adrian Sevcenco wrote:
> On 05/23/2011 10:16 AM, Axel Naumann wrote:

>> Hi,

> Hi!
>
>> even though I don't see how this is related to ROOT: you could check

> err.. sorry.. how can i identify the file type __IN_ROOT__ ?
>
>> whether the file starts with "<?xml". XML files don't *have* to, but
>> they should, and most do.

> the purpose it to feed a proper argument to a function that creates a
> TChain.
>
> Thanks,
> Adrian
>
>>
>> Cheers, Axel.
>>
>> On 5/22/11 12:52 PM, Adrian Sevcenco wrote:
>>> Hi! Is there a way to identify the file type other than using a bash
>>> command like:
>>> file -b $file | awk '{print $1}'
>>>
>>> I want to distinguish between XML and ASCII file types.
>>> Thank you,
>>> Adrian
>>>
>>> ----------------------------------------------
>>> Adrian Sevcenco                              |
>>> Institute of Space Sciences - ISS, Romania   |
>>> adrian.sevcenco at {cern.ch,spacescience.ro} |
>>> ----------------------------------------------
>>>
>>
>>

>
>
Received on Mon May 23 2011 - 15:55:12 CEST

This archive was generated by hypermail 2.2.0 : Mon May 23 2011 - 17:50:01 CEST