dart-sdk/runtime/bin/fdutils.h
Josh Soref 50b94ef9fc Spelling runtime bin
TEST=build VM

Closes: https://github.com/dart-lang/sdk/pull/50862

GitOrigin-RevId: ae54b37666f70f670ee3af11c984c7e9a7e9da26
Change-Id: I459fda0439a1cd368f488a70d84ee6bb915e60bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277761
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-01-06 07:48:22 +00:00

54 lines
1.8 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_BIN_FDUTILS_H_
#define RUNTIME_BIN_FDUTILS_H_
#include "bin/builtin.h"
#include "platform/globals.h"
namespace dart {
namespace bin {
class FDUtils {
public:
static bool SetCloseOnExec(intptr_t fd);
static bool SetNonBlocking(intptr_t fd);
static bool SetBlocking(intptr_t fd);
// Checks whether the file descriptor is blocking. If the function
// returns true the value pointed to by is_blocking will be set to
// the blocking state of the file descriptor. If the function
// returns false the system call for checking the file descriptor
// failed and the value pointed to by is_blocking is not modified.
static bool IsBlocking(intptr_t fd, bool* is_blocking);
static intptr_t AvailableBytes(intptr_t fd);
// Reads the requested number of bytes from a file descriptor. This
// function will only return on short reads if an error occurs in
// which case it returns -1 and errno is still valid. The file
// descriptor must be in blocking mode.
static ssize_t ReadFromBlocking(int fd, void* buffer, size_t count);
// Writes the requested number of bytes to a file descriptor. This
// function will only return on short writes if an error occurs in
// which case it returns -1 and errno is still valid. The file
// descriptor must be in blocking mode.
static ssize_t WriteToBlocking(int fd, const void* buffer, size_t count);
// Closes fd without modifying errno.
static void SaveErrorAndClose(intptr_t fd);
private:
DISALLOW_ALLOCATION();
DISALLOW_IMPLICIT_CONSTRUCTORS(FDUtils);
};
} // namespace bin
} // namespace dart
#endif // RUNTIME_BIN_FDUTILS_H_