# Path: s3transfer/compat.py
# SOCKET_ERROR = ConnectionError
# 
# def fallocate(fileobj, size):
#     if hasattr(os, 'posix_fallocate'):
#         os.posix_fallocate(fileobj.fileno(), 0, size)
#     else:
#         fileobj.truncate(size)
# 
# def rename_file(current_filename, new_filename):
#     try:
#         os.remove(new_filename)
#     except OSError as e:
#         if not e.errno == errno.ENOENT:
#             # We only want to a ignore trying to remove
#             # a file that does not exist.  If it fails
#             # for any other reason we should be propagating
#             # that exception.
#             raise
#     os.rename(current_filename, new_filename)


import functools
import logging
import math
import os
import random
import socket
import stat
import string
import threading
from collections import defaultdict
from botocore.exceptions import IncompleteReadError, ReadTimeoutError
from s3transfer.compat import SOCKET_ERROR, fallocate, rename_file
        """
        # If it does not exist, it must be a new file so it cannot be
        # a special file.
        if not os.path.exists(filename):
            return False
        mode = os.stat(filename).st_mode
        # Character special device.
        if stat.S_ISCHR(mode):
            return True
        # Block special device
        if stat.S_ISBLK(mode):
            return True
        # Named pipe / FIFO
        if stat.S_ISFIFO(mode):
            return True
        # Socket.
        if stat.S_ISSOCK(mode):
            return True
        return False

    def get_temp_filename(self, filename):
        suffix = os.extsep + random_file_extension()
        path = os.path.dirname(filename)
        name = os.path.basename(filename)
        temp_filename = name[: self._MAX_FILENAME_LEN - len(suffix)] + suffix
        return os.path.join(path, temp_filename)

    def allocate(self, filename, size):
        try:
            with self.open(filename, 'wb') as f:

# Path: s3transfer/compat.py
# SOCKET_ERROR = ConnectionError
# 
# def fallocate(fileobj, size):
#     if hasattr(os, 'posix_fallocate'):
#         os.posix_fallocate(fileobj.fileno(), 0, size)
#     else:
#         fileobj.truncate(size)
# 
# def rename_file(current_filename, new_filename):
#     try:
#         os.remove(new_filename)
#     except OSError as e:
#         if not e.errno == errno.ENOENT:
#             # We only want to a ignore trying to remove
#             # a file that does not exist.  If it fails
#             # for any other reason we should be propagating
#             # that exception.
#             raise
#     os.rename(current_filename, new_filename)


# Path: s3transfer/utils.py
import functools
import logging
import math
import os
import random
import socket
import stat
import string
import threading
from collections import defaultdict
from botocore.exceptions import IncompleteReadError, ReadTimeoutError
from s3transfer.compat import SOCKET_ERROR, fallocate, rename_file

        """
        # If it does not exist, it must be a new file so it cannot be
        # a special file.
        if not os.path.exists(filename):
            return False
        mode = os.stat(filename).st_mode
        # Character special device.
        if stat.S_ISCHR(mode):
            return True
        # Block special device
        if stat.S_ISBLK(mode):
            return True
        # Named pipe / FIFO
        if stat.S_ISFIFO(mode):
            return True
        # Socket.
        if stat.S_ISSOCK(mode):
            return True
        return False

    def get_temp_filename(self, filename):
        suffix = os.extsep + random_file_extension()
        path = os.path.dirname(filename)
        name = os.path.basename(filename)
        temp_filename = name[: self._MAX_FILENAME_LEN - len(suffix)] + suffix
        return os.path.join(path, temp_filename)

    def allocate(self, filename, size):
        try:
            with self.open(filename, 'wb') as f:

                fallocate(f, size)