Re: identify the file type

From: Adrian Sevcenco <Adrian.Sevcenco_at_cern.ch>
Date: Mon, 23 May 2011 18:38:07 +0300


On 05/23/2011 04:55 PM, Axel Naumann wrote:
> 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)

Thanks!

> 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


Received on Mon May 23 2011 - 17:38:17 CEST

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