Declaring run time variables

2014-08-04 Thread splatterdash via Digitalmars-d-learn
Hello everyone, I'm trying to write a command-line application that can detect whether the input file is gzipped or not. Sounds simple enough, but I can't seem to do it properly in D (this is my first foray to the language). After checking whether the file is gzipped or not, I try to create

Re: Declaring run time variables

2014-08-04 Thread splatterdash via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:09:49 UTC, anonymous wrote: On Monday, 4 August 2014 at 22:00:18 UTC, splatterdash wrote: ``` File f = File("input_file") // detect gzip ... if (isGzip) { auto fileIter = new MyFileReader!GzipIterator(f) } else { auto fileIter = new MyFileReader!NormalI

Re: Declaring run time variables

2014-08-05 Thread splatterdash via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:45:15 UTC, anonymous wrote: On Monday, 4 August 2014 at 22:18:24 UTC, splatterdash wrote: Indeed I do. I'm not sure which type I should use for the common base type, though. MyFileReader is a templated class, so using it plainly did not work. I also tried `InputR

Best practices for testing functions that opens files

2014-08-05 Thread splatterdash via Digitalmars-d-learn
Hi all, Is there a recommended way to test functions that opens and iterates over files? The unittest block seems more suited for testing functions whose input and output can be defined in the program itself. I'm wondering if there is a better way to test functions that open files with specif