system/Open: add OpenWriteOnly(), OpenDirectory()
This commit is contained in:
		@@ -43,6 +43,30 @@ OpenReadOnly(const char *path)
 | 
				
			|||||||
	return fd;
 | 
						return fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UniqueFileDescriptor
 | 
				
			||||||
 | 
					OpenWriteOnly(const char *path, int flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						UniqueFileDescriptor fd;
 | 
				
			||||||
 | 
						if (!fd.Open(path, O_WRONLY|flags))
 | 
				
			||||||
 | 
							throw FormatErrno("Failed to open '%s'", path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return fd;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _WIN32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UniqueFileDescriptor
 | 
				
			||||||
 | 
					OpenDirectory(const char *path, int flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						UniqueFileDescriptor fd;
 | 
				
			||||||
 | 
						if (!fd.Open(path, O_DIRECTORY|O_RDONLY|flags))
 | 
				
			||||||
 | 
							throw FormatErrno("Failed to open '%s'", path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return fd;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __linux__
 | 
					#ifdef __linux__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UniqueFileDescriptor
 | 
					UniqueFileDescriptor
 | 
				
			||||||
@@ -75,6 +99,16 @@ OpenReadOnly(FileDescriptor directory, const char *name, int flags)
 | 
				
			|||||||
	return fd;
 | 
						return fd;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UniqueFileDescriptor
 | 
				
			||||||
 | 
					OpenWriteOnly(FileDescriptor directory, const char *name, int flags)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						UniqueFileDescriptor fd;
 | 
				
			||||||
 | 
						if (!fd.Open(directory, name, O_WRONLY|flags))
 | 
				
			||||||
 | 
							throw FormatErrno("Failed to open '%s'", name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return fd;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UniqueFileDescriptor
 | 
					UniqueFileDescriptor
 | 
				
			||||||
OpenDirectory(FileDescriptor directory, const char *name, int flags)
 | 
					OpenDirectory(FileDescriptor directory, const char *name, int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,17 @@ class UniqueFileDescriptor;
 | 
				
			|||||||
UniqueFileDescriptor
 | 
					UniqueFileDescriptor
 | 
				
			||||||
OpenReadOnly(const char *path);
 | 
					OpenReadOnly(const char *path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UniqueFileDescriptor
 | 
				
			||||||
 | 
					OpenWriteOnly(const char *path, int flags=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _WIN32
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UniqueFileDescriptor
 | 
				
			||||||
 | 
					OpenDirectory(const char *name, int flags=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __linux__
 | 
					#ifdef __linux__
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UniqueFileDescriptor
 | 
					UniqueFileDescriptor
 | 
				
			||||||
@@ -47,6 +58,9 @@ OpenPath(FileDescriptor directory, const char *name, int flags=0);
 | 
				
			|||||||
UniqueFileDescriptor
 | 
					UniqueFileDescriptor
 | 
				
			||||||
OpenReadOnly(FileDescriptor directory, const char *name, int flags=0);
 | 
					OpenReadOnly(FileDescriptor directory, const char *name, int flags=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UniqueFileDescriptor
 | 
				
			||||||
 | 
					OpenWriteOnly(FileDescriptor directory, const char *name, int flags=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UniqueFileDescriptor
 | 
					UniqueFileDescriptor
 | 
				
			||||||
OpenDirectory(FileDescriptor directory, const char *name, int flags=0);
 | 
					OpenDirectory(FileDescriptor directory, const char *name, int flags=0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user