Skip to content

Commit f838353

Browse files
dgryskicatamorphism
authored andcommitted
---
yaml --- r: 31449 b: refs/heads/dist-snap c: cdd052f h: refs/heads/master i: 31447: 06e5c49 v: v3
1 parent a17e1b6 commit f838353

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 872ef0f3124eaca8e0c67095c4117c93922b670d
10+
refs/heads/dist-snap: cdd052f6ea1fb268a25e467147643344ec9a6b8c
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libcore/io.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,20 +330,25 @@ fn with_str_reader<T>(s: ~str, f: fn(reader) -> T) -> T {
330330
// Writing
331331
enum fileflag { append, create, truncate, no_flag, }
332332

333+
// What type of writer are we?
334+
enum writer_type { screen, file }
335+
333336
// FIXME (#2004): Seekable really should be orthogonal.
334337
// FIXME (#2004): eventually u64
335338
iface writer {
336339
fn write(v: &[const u8]);
337340
fn seek(int, seek_style);
338341
fn tell() -> uint;
339342
fn flush() -> int;
343+
fn get_type() -> writer_type;
340344
}
341345

342346
impl <T: writer, C> of writer for {base: T, cleanup: C} {
343347
fn write(bs: &[const u8]) { self.base.write(bs); }
344348
fn seek(off: int, style: seek_style) { self.base.seek(off, style); }
345349
fn tell() -> uint { self.base.tell() }
346350
fn flush() -> int { self.base.flush() }
351+
fn get_type() -> writer_type { file }
347352
}
348353

349354
impl of writer for *libc::FILE {
@@ -364,6 +369,13 @@ impl of writer for *libc::FILE {
364369
}
365370
fn tell() -> uint { libc::ftell(self) as uint }
366371
fn flush() -> int { libc::fflush(self) as int }
372+
fn get_type() -> writer_type {
373+
let fd = libc::fileno(self);
374+
if libc::isatty(fd) == 0 {
375+
ret file;
376+
}
377+
ret screen;
378+
}
367379
}
368380

369381
fn FILE_writer(f: *libc::FILE, cleanup: bool) -> writer {
@@ -399,6 +411,9 @@ impl of writer for fd_t {
399411
fail;
400412
}
401413
fn flush() -> int { 0 }
414+
fn get_type() -> writer_type {
415+
if libc::isatty(self) == 0 { file } else { screen }
416+
}
402417
}
403418

404419
class fd_res {
@@ -646,6 +661,7 @@ impl of writer for mem_buffer {
646661
}
647662
fn tell() -> uint { self.pos }
648663
fn flush() -> int { 0 }
664+
fn get_type() -> writer_type { ret file }
649665
}
650666
651667
fn mem_buffer() -> mem_buffer {

branches/dist-snap/src/libstd/net_tcp.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,9 @@ impl tcp_socket_buf of io::writer for @tcp_socket_buf {
840840
fn flush() -> int {
841841
0
842842
}
843+
fn get_type() -> io::writer_type {
844+
io::file
845+
}
843846
}
844847

845848
// INTERNAL API

0 commit comments

Comments
 (0)