MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / FileObject

Class FileObject

source/TextIO.cpp:706–1035  ·  view source on GitHub ↗

FileObject: exports TextFile interfaces to the scripts.

Source from the content-addressed store, hash-verified

704
705// FileObject: exports TextFile interfaces to the scripts.
706class FileObject : public Object
707{
708 FileObject() {}
709 ~FileObject() {}
710
711 enum MemberID {
712 // methods
713 M_Read,
714 M_Write,
715 M_ReadLine,
716 M_WriteLine,
717 M_RawRead,
718 M_RawWrite,
719 M_Close,
720 M_Seek,
721 // properties
722 P_Pos,
723 P_Length,
724 P_AtEOF,
725 P_Handle,
726 P_Encoding
727 };
728
729 static ObjectMember sMembers[];
730 static Object *sPrototype;
731
732 friend void ::DefineFileClass();
733
734 enum NumReadWriteFlags
735 {
736 F_SIZE_MASK = 0xF,
737 F_READ = 0x10,
738 F_WRITE = 0,
739 F_SIGNED = 0x20,
740 F_UNSIGNED = 0,
741 F_FLOAT = 0x40
742 };
743
744 ResultType NumReadWrite(ResultToken &aResultToken, int aID, int aFlags, ExprTokenType *aParam[], int aParamCount)
745 {
746 const bool reading = aID & F_READ;
747 const BOOL is_signed = aID & F_SIGNED, is_float = aID & F_FLOAT;
748 const DWORD size = aID & F_SIZE_MASK;
749
750 union {
751 __int64 i8;
752 int i4;
753 short i2;
754 char i1;
755 double d;
756 float f;
757 } buf;
758
759 if (reading)
760 {
761 buf.i8 = 0;
762 if ( !mFile.Read(&buf, size) )
763 _o_return_empty; // Fail.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected