contrib/python-zstandard/zstd/deprecated/zbuff_common.c
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 04 Nov 2022 17:35:44 -0400
changeset 49572 c4f07a011714
parent 37495 b1fb341d8a61
permissions -rw-r--r--
util: implement `writelines()` on atomictempfile With typehints on the vfs objects, pytype will flag this: FAILED: /mnt/c/Users/Matt/hg/.pytype/pyi/mercurial/patch.pyi /usr/bin/python3.8 -m pytype.single --imports_info /mnt/c/Users/Matt/hg/.pytype/imports/mercurial.patch.imports --module-name mercurial.patch -V 3.7 -o /mnt/c/Users/Matt/hg/.pytype/pyi/mercurial/patch.pyi --analyze-annotated --nofail --quick /mnt/c/Users/Matt/hg/mercurial/patch.py File "/mnt/c/Users/Matt/hg/mercurial/patch.py", line 535, in writerej: No attribute 'writelines' on mercurial.util.atomictempfile [attribute-error] In Union[ mercurial.util.atomictempfile, mercurial.vfs.checkambigatclosing, mercurial.vfs.delayclosedfile, mercurial.windows.fdproxy, mercurial.windows.mixedfilemodewrapper ] It's not a real problem there (atomictempfile is only created by passing different args), but it's reasonable for this to implement the function and behave like a normal file. There are other functions missing that can be added if/when needed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37495
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
/*
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
 * All rights reserved.
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
 *
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
 * This source code is licensed under both the BSD-style license (found in the
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
 * in the COPYING file in the root directory of this source tree).
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
 * You may select, at your option, one of the above-listed licenses.
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
 */
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
/*-*************************************
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
*  Dependencies
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
***************************************/
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
#include "error_private.h"
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
#include "zbuff.h"
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
/*-****************************************
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
*  ZBUFF Error Management  (deprecated)
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
******************************************/
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
/*! ZBUFF_isError() :
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
*   tells if a return value is an error code */
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
unsigned ZBUFF_isError(size_t errorCode) { return ERR_isError(errorCode); }
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
/*! ZBUFF_getErrorName() :
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
*   provides error code string from function result (useful for debugging) */
b1fb341d8a61 zstandard: vendor python-zstandard 0.9.0
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
const char* ZBUFF_getErrorName(size_t errorCode) { return ERR_getErrorName(errorCode); }