Hana 9e216da9ef go.mod: add go.mod and move pygments to third_party
After go1.16, go will use module mode by default,
even when the repository is checked out under GOPATH
or in a one-off directory. Add go.mod, go.sum to keep
this repo buildable without opting out of the module
mode.

> go mod init github.com/mmcgrana/gobyexample
> go mod tidy
> go mod vendor

In module mode, the 'vendor' directory is special
and its contents will be actively maintained by the
go command. pygments aren't the dependency the go will
know about, so it will delete the contents from vendor
directory. Move it to `third_party` directory now.

And, vendor the blackfriday package.

Note: the tutorial contents are not affected by the
change in go1.16 because all the examples in this
tutorial ask users to run the go command with the
explicit list of files to be compiled (e.g.
`go run hello-world.go` or `go build command-line-arguments.go`).
When the source list is provided, the go command does
not have to compute the build list and whether it's
running in GOPATH mode or module mode becomes irrelevant.
2021-02-15 16:45:26 -05:00

175 lines
3.2 KiB
Hy

/*
* This file is part of the Hybris programming language.
*
* Copyleft of Francesco Morucci aka merlok <merlok@ihteam.net>
*
* Hybris is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Hybris is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Hybris. If not, see <http://www.gnu.org/licenses/>.
*/
import std.io.file;
class File {
protected file, fileName, mode;
public method File( fileName, mode ){
me.fileName = fileName;
me.mode = mode;
me.file = fopen ( me.fileName, me.mode);
}
private method isBinary(){
return me.mode.find("b") != false;
}
public method File ( file ){
me.file = file;
}
private method __expire() {
me.close();
}
public method close(){
fclose( me.file );
}
public method readLine(){
return line = fgets( me.file );
}
public method getFileName(){
return me.fileName;
}
public method getSize(){
return fsize( me.fileName );
}
public method getPosition(){
return ftell( me.file );
}
public method readAll(){
text = "";
line = "";
while ( ( line = fgets(me.file) ) != 0 ){
text += line;
}
return text;
}
public method read(){
byte = ' ';
if ( fread( me.file, byte) > 0 ) {
return byte;
}
else {
return -1;
}
}
public method read( bytes ) {
word = "";
byte = ' ';
if ( fread( me.file, byte, bytes) > 0 ) {
word += byte;
}
else {
return -1;
}
return word;
}
public method read ( seek, seekType ){
if ( me.seek( seek, seekType) == 0 ) {
return -1;
}
return me.read();
}
public method read ( bytes, seek, seekType ){
if ( me.seek( seek, seekType) == 0 ) {
return -1;
}
return me.read( bytes );
}
public method readType ( type ){
if ( me.isBinary() == false ) {
return -1;
}
if ( fread (me.file, type ) > 0 ) {
return type;
}
else {
return -1;
}
}
operator >> ( object ){
return me.readType(object);
}
public method readType ( type, bytes ){
if ( me.isBinary() == false ) {
return -1;
}
if ( fread (me.file, type, bytes ) > 0){
return type;
}
else {
return -1;
}
}
public method readType ( type, seek, seekType ){
if ( ( me.isBinary() == false ) | ( me.seek( seek, seekType) == 0 ) ) {
return -1;
}
return me.readType( type );
}
public method readType( type, bytes, seek, seekType){
if ( ( me.isBinary() == false ) | ( me.seek( seek, seekType) == 0 ) ) {
return -1;
}
return me.readType( type, bytes );
}
public method write( data ){
return fwrite( me.file, data );
}
operator << ( object ){
return me.write(object);
}
public method write ( data, bytes ){
return fwrite( me.file, data, bytes);
}
public method seek( pos, mode ){
return fseek( me.file, pos, mode );
}
public method merge ( fileName ){
text = file ( fileName );
return me.write ( me.file, text );
}
}