* Create a File object from an existing file descriptor.
* Takes ownership of the file descriptor if ownsFd is true.
*/
- /* implicit */ File(int fd,
- bool ownsFd = false);
+ explicit File(int fd, bool ownsFd = false);
/**
* Open and create a file object. Throws on error.
*/
- /* implicit */ File(const char* name,
- int flags = O_RDONLY,
- mode_t mode = 0644);
+ explicit File(const char* name, int flags = O_RDONLY, mode_t mode = 0644);
~File();
/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
init(std::move(file), offset, length, PROT_READ, false);
}
+MemoryMapping::MemoryMapping(const char* name, off_t offset, off_t length)
+ : MemoryMapping(File(name), offset, length) { }
+
+MemoryMapping::MemoryMapping(int fd, off_t offset, off_t length)
+ : MemoryMapping(File(fd), offset, length) { }
+
void MemoryMapping::init(File file,
off_t offset, off_t length,
int prot,
/*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
off_t offset=0,
off_t length=-1);
+ explicit MemoryMapping(const char* name,
+ off_t offset=0,
+ off_t length=-1);
+
+ explicit MemoryMapping(int fd,
+ off_t offset=0,
+ off_t length=-1);
+
virtual ~MemoryMapping();
/**
};
} // !detail
+
/**
* Generator which reads lines from a file.
* Note: This produces StringPieces which reference temporary strings which are
| resplit(delim);
}
+inline auto byLine(int fd, char delim = '\n')
+ -> decltype(byLine(File(fd), delim)) { return byLine(File(fd), delim); }
+
+inline auto byLine(const char* f, char delim = '\n')
+ -> decltype(byLine(File(f), delim)) { return byLine(File(f), delim); }
+
}} // !folly::gen