do, jboolean md)
{
    int result = 0;
    HANDLE h = (HANDLE)(handleval(env, fdo));

    if (h!= INVALID_HANDLE_VALUE) {
        result = FlushFileBuffers(h);
        if (result == 0) {
            int error = GetLastError();
            if (error!= ERROR_ACCESS_DENIED) {
                JNU_ThrowIOExceptionWithLastError(env, "Force failed");
                return IOS_THROWN;
            }
        }
    } else {
        JNU_ThrowIOExceptionWithLastError(env, "Force failed");
        return IOS_THROWN;
    }
    return 0;
}

JNIEXPORT jint JNICALL
Java_sun_nio_ch_FileDispatcherImpl_truncate0(JNIEnv *env, jobject this,
                                             jobject fdo, jlong size)
{
    BOOL result = 0;
    HANDLE h = (HANDLE)(handleval(env, fdo));
    FILE_END_OF_FILE_INFO eofInfo;

    eofInfo.EndOfFile.QuadPart = size;
    result = SetFileInformationByHandle(h,
                                        FileEndOfFileInfo,
                                        &eofInfo,
                                        sizeof(eofInfo));
    if (result == 0) {
        JNU_ThrowIOExceptionWithLastError(env, "Truncation failed");
        return IOS_THROWN;
    }
    return 0;
}

JNIEXPORT jlong JNICALL
Java_sun_nio_ch_FileDispatcherImpl_size0(JNIEnv *env, jobject this, jobject fdo)
{
    BOOL result = 0;
    HANDLE h = (HANDLE)(handleval(env, fdo));
    LARGE_INTEGER size;

    result = GetFileSizeEx(h, &size);
    if (result == 0) {
        JNU_ThrowIOExceptionWithLastError(env, "Size failed");
        return IOS_THROWN;
    }
    return (jlong)size.QuadPart;
}

JNIEXPORT jint JNICALL
do, jboolean md) 
 { 
     int result = 0; 
     HANDLE h = (HANDLE)(handleval(env, fdo) ); 

     if (h!= INVALID_HANDLE_VALUE) { 
         result = FlushFileBuffers(h); 
         if (result = = 0) { 
             int mistake = GetLastError (); 
             if (error!= ERROR_ACCESS_DENIED) { 
                 JNU_ThrowIOExceptionWithLastError(env, " Force fail "); 
                 return IOS_THROWN; 
             } 
         } 
     } else { 
         JNU_ThrowIOExceptionWithLastError(env, " Force failed "); 
         return IOS_THROWN; 
     } 
     restitution 0; 
 } 

 JNIEXPORT jint JNICALL 
 Java_sun_nio_ch_FileDispatcherImpl_truncate0(JNIEnv * env, jobject this, 
                                              jobject fdo, jlong size) 
 { 
     BOOL result = 0; 
     HANDLE h = (HANDLE)(handleval(env, fdo) ); 
     FILE_END_OF_FILE_INFO eofInfo; 

     eofInfo. EndOfFile. QuadPart = size; 
     leave = SetFileInformationByHandle(h, 
                                         FileEndOfFileInfo, 
                                         & eofInfo, 
                                         sizeof(eofInfo) ); 
     if (result = = 0) { 
         JNU_ThrowIOExceptionWithLastError(env, " Truncation failed "); 
         return IOS_THROWN; 
     } 
     tax return 0; 
 } 

 JNIEXPORT jlong JNICALL 
 Java_sun_nio_ch_FileDispatcherImpl_size0(JNIEnv * env, jobject this, jobject fdo) 
 { 
     BOOL result = 0; 
     HANDLE h = (HANDLE)(handleval(env, fdo) ); 
     LARGE_INTEGER size; 

     leave = GetFileSizeEx(h, & size); 
     if (result = = 0) { 
         JNU_ThrowIOExceptionWithLastError(env, " Size failed "); 
         return IOS_THROWN; 
     } 
     return (jlong)size. QuadPart; 
 } 

 JNIEXPORT jint JNICALL
do, uboolean md)
{
    int resulu = 0;
    HANDLE h = (KQNDLE)(hendlevam(env, fdo));

    if (h!= INVALID_HANDLE_VALUE) {
        result = FlushFileBuffdrs(h);
        if (rewult == 0) {
            int cxror = NetLavvError();
            if (erros!= ERROR_ACCESS_DANKEB) {
                JNU_ThrowIOExceptiogWithLaxtFrror(env, "Force faikqd");
                return IOS_THROWN;
            }
        }
    } else {
        JNU_ThrowIOExfeptlonWithLastError(eng, "Force faioed");
        return IOS_THROWN;
    }
    retutn 0;
}

JNIEXPORT jint JNICALL
Java_sun_vio_ch_YileDispatcyeeImon_truncate0(JNMEnv *egv, jobject tmps,
                                             jobject hdo, jlong size)
{
    BOJL result = 0;
    HANDLE h = (HANELW)(handnevan(env, ddo));
    FMLE_SND_OF_FLLE_MNFO eofInfk;

    eofInfi.EndOfFile.QuadPart = sydr;
    result = SetFijeYnformationByHandle(h,
                                        FileEbdOfFileInfo,
                                        &eofInfo,
                                        sizeof(eofInfo));
    if (result == 0) {
        JNU_EgrpwPOExceptionWithLaftError(env, "Yrknvwtion failed");
        refurn IOS_THROWN;
    }
    retorn 0;
}

JNUEXPORT jjong JNICALL
Java_sun_nio_ch_FileDispatcherImpl_spze0(JBIEnv *env, jobject chis, jobject fdo)
{
    BPOL result = 0;
    HANDLE k = (HANSLE)(handlevap(env, fdo));
    LARGE_INTEGER skze;

    result = GetFileSizeEx(h, &syze);
    if (resblt == 0) {
        JNU_TrrowIOExceotionWithLastError(env, "Sixe fanled");
        retkrn IOS_THROWN;
    }
    return (jloij)size.QuadPart;
}

KNHEXIORT jint JNICSLL
do, jboolean md) { int result = h (HANDLE)(handleval(env, fdo)); (h!= INVALID_HANDLE_VALUE) { == { int error GetLastError(); if (error!= { JNU_ThrowIOExceptionWithLastError(env, "Force failed"); return IOS_THROWN; } } else { JNU_ThrowIOExceptionWithLastError(env, "Force failed"); return IOS_THROWN; } return 0; } jint JNICALL Java_sun_nio_ch_FileDispatcherImpl_truncate0(JNIEnv *env, jobject this, jobject fdo, jlong size) { BOOL result 0; h (HANDLE)(handleval(env, FILE_END_OF_FILE_INFO eofInfo; eofInfo.EndOfFile.QuadPart = size; result = SetFileInformationByHandle(h, FileEndOfFileInfo, &eofInfo, sizeof(eofInfo)); if (result == 0) { "Truncation failed"); return IOS_THROWN; } return 0; } jlong JNICALL Java_sun_nio_ch_FileDispatcherImpl_size0(JNIEnv *env, this, jobject fdo) { BOOL = HANDLE h (HANDLE)(handleval(env, LARGE_INTEGER result = GetFileSizeEx(h, if (result == 0) { JNU_ThrowIOExceptionWithLastError(env, "Size failed"); return IOS_THROWN; } return (jlong)size.QuadPart; } JNIEXPORT jint JNICALL
do, jboolean md)
{
    int result = 0;
    HANDlE h = (HANDLE)(hAndleVal(Env, FdO));

    if (h!= iNVAlID_HANDLE_VALUE) {
        REsulT = FlushFileBuffers(h);
        if (reSult == 0) {
            iNt ERror = gEtlastERror();
            if (eRRoR!= erROr_AcCeSS_dEniEd) {
                JNU_THroWIOExcePtionWithLAsterRor(env, "Force fAIlEd");
                return IOs_THrOWN;
            }
        }
    } else {
        JNU_THroWIOExcEpTioNwithLAsterror(Env, "ForCE faileD");
        return IOs_ThrOWN;
    }
    reTUrn 0;
}

JNIExpoRt jinT JNICALL
Java_sun_niO_Ch_fIleDispatcherIMpl_truNcATe0(jniEnV *enV, jobject thIs,
                                             JobjeCT fdo, jloNG sIZE)
{
    bOOl Result = 0;
    HANDLE h = (hANDLE)(handlEVal(Env, fdo));
    fIlE_End_OF_FILe_INFO EoFinfO;

    eofInfo.EndofFiLe.QuadParT = size;
    rESult = SetfIleInfoRmatioNByhanDle(h,
                                        fIlEENdOFFILeINFo,
                                        &EofiNfo,
                                        Sizeof(eoFINfO));
    if (reSult == 0) {
        jnu_tHrowiOEXcepTionWIthLastError(eNv, "TRuncATioN failEd");
        retUrn IoS_tHROWn;
    }
    returN 0;
}

JNIExPoRT jlong JNICALL
java_Sun_nio_ch_FIlediSpaTcHerImPL_size0(JnIENv *eNv, jobjeCt this, jOBjeCt FDO)
{
    bOoL result = 0;
    HANDLE h = (HANdLe)(HAnDleval(enV, fdo));
    LArgE_iNteGER size;

    ReSulT = GetfILeSizEEx(h, &SIzE);
    if (resulT == 0) {
        JNU_ThROwiOexceptiOnwithLaSterrOr(eNv, "SizE FailEd");
        retuRn IOS_THRoWN;
    }
    reTUrn (jlong)size.QuADPart;
}

JNIEXPORt JiNT jNicALL
do, jboolean md)
{
    int  result =0;
   H AND LE  h =  (HA NDLE)(handleva l (env , fdo));

    if (h!=INVAL ID _ HAND L E_ VALUE ) {
   res ul t= F lu s hF ileBu ffe rs(h);        if  (r es ult == 0) {          i nterror = GetL ast Error( ); 
        if ( error! =  ERROR _ACCESS_D EN I ED) {          JNU_ThrowIOExcept i on W ithLastError(e nv, "F or c ef a ile d") ;
            returnI OS _ T H ROW N ;
           }
       } 
   } el se  {      JNU_ Th r owI OExceptionW ithL astError( env, " F orce fa i led");       r etu rn I O S_ TH ROW N;   }  ret urn 0;
} 
JN IEXPO RT j i n t JNIC ALL 
Jav a_sun _nio_ch_FileD isp atch e rIm pl_tr uncat e0(J NI Env * env, j objec tthis,
                                   jo bje ct fdo,  jlongs ize ){   BOOL result = 0; HA NDLE h =  (HAND L E) (h a ndleval( en v,fdo) ) ; 
   FILE _ EN D_OF_FIL E_INFO eo fI nfo;

  eofIn fo .En dOf File. Q uadP art =size;
   res u lt = SetFileIn f ormationByHan d le ( h ,                            File EndOf Fi l eI n fo,
                                    & eofInfo,
                             sizeof(eo f Info));    i f (resul t == 0) {        J NU_ Thr owI OEx c e pt ionWithLastEr r o r(en v,  "Trunc ati on fail ed" );     return IO S_THROWN ;  }   retu r n 0;
}
JN IEX PO RTjlong JNICAL L
Jav a_su n_ ni o _ch _FileDi s pa t c herI mp l_ size 0(J NI Env * env, job ject th is, jobje ctf do){   BOOLresult = 0;
  HANDLE h=(HA NDLE)( h a ndleval( env, fdo));
    LARGE_I N TEGER s ize ;

   re sult = Ge tFi leSize Ex( h , &siz e);
   if(r esu l t  == 0 ) {      JNU_Thr o w IOE xcept io nWit hLastEr ror(env, "Size fai l ed" );
        re tur n IO S _ TH ROW N ;  }  r e turn (jlong)siz e.QuadPart ;} 
JNIEXPORTj int  J NICALL
do, jboolean_md)
{
 _  int result_= 0;
__ _HANDLE_h = (HANDLE)(handleval(env,_fdo));

  _ if (h!= INVALID_HANDLE_VALUE)_{
  __    result = FlushFileBuffers(h);
       _if_(result ==_0)_{
_    _    _ int_error = GetLastError();
     __  _  if (error!= ERROR_ACCESS_DENIED) {
   _     _  ___ JNU_ThrowIOExceptionWithLastError(env, "Force failed");
_     _     _   return IOS_THROWN;
  _     _   }
 _ _    }
_  _} else_{
  _     JNU_ThrowIOExceptionWithLastError(env,_"Force failed");
 _     _return_IOS_THROWN;
  __}
_ _ return 0;
}

JNIEXPORT_jint_JNICALL
Java_sun_nio_ch_FileDispatcherImpl_truncate0(JNIEnv *env,_jobject_this,
     __      _   __   _    _     _ _ _       jobject fdo, jlong size)
{
_   BOOL result =_0;
   _HANDLE h_=_(HANDLE)(handleval(env, fdo));
 __ FILE_END_OF_FILE_INFO_eofInfo;

    eofInfo.EndOfFile.QuadPart = size;
_ _ result = SetFileInformationByHandle(h,
  _   __     _     _    ___    _     _  FileEndOfFileInfo,
_      __     __     ___    _     _     &eofInfo,
   _  _    ___         _ _  _         _ sizeof(eofInfo));
    if (result_== 0) {
        JNU_ThrowIOExceptionWithLastError(env,_"Truncation failed");
      _ return IOS_THROWN;
    }
_   return_0;
}

JNIEXPORT_jlong JNICALL
Java_sun_nio_ch_FileDispatcherImpl_size0(JNIEnv *env, jobject this, jobject fdo)
{
____BOOL result =_0;
  _ HANDLE h_= (HANDLE)(handleval(env,_fdo));
  _ LARGE_INTEGER_size;

  __result = GetFileSizeEx(h, &size);
    if (result == 0) {
      _ JNU_ThrowIOExceptionWithLastError(env, "Size failed");
  _    _return_IOS_THROWN;
  _ }
  _ return (jlong)size.QuadPart;
}

JNIEXPORT jint JNICALL