ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

VOID NTAPI FatSetFullFileNameInFcb ( IN PFAT_IRP_CONTEXT  IrpContext,
IN PFCB  Fcb 
)

Definition at line 688 of file fcb.c.

Referenced by FatCreateDcb(), FatiCreate(), FatiQueryNameInformation(), and FatNotifyReportChange().

{
    UNICODE_STRING LongName;
    PFCB CurFcb = Fcb;
    PFCB StopFcb;
    PWCHAR TmpBuffer;
    ULONG PathLength = 0;

    /* Do nothing if it's already set */
    if (Fcb->FullFileName.Buffer) return;

    /* Allocate a temporary buffer */
    LongName.Length = 0;
    LongName.MaximumLength = FF_MAX_FILENAME * sizeof(WCHAR);
    LongName.Buffer =
        FsRtlAllocatePoolWithTag(PagedPool,
                                 FF_MAX_FILENAME * sizeof(WCHAR),
                                 TAG_FILENAME);

    /* Go through all parents to calculate needed length */
    while (CurFcb != Fcb->Vcb->RootDcb)
    {
        /* Does current FCB have FullFileName set? */
        if (CurFcb != Fcb &&
            CurFcb->FullFileName.Buffer)
        {
            /* Yes, just use it! */
            PathLength += CurFcb->FullFileName.Length;

            Fcb->FullFileName.Buffer =
                FsRtlAllocatePoolWithTag(PagedPool,
                                         PathLength,
                                         TAG_FILENAME);

            RtlCopyMemory(Fcb->FullFileName.Buffer,
                          CurFcb->FullFileName.Buffer,
                          CurFcb->FullFileName.Length);

            break;
        }

        /* Sum up length of a current item */
        PathLength += CurFcb->FileNameLength + sizeof(WCHAR);

        /* Go to the parent */
        CurFcb = CurFcb->ParentFcb;
    }

    /* Allocate FullFileName if it wasn't already allocated above */
    if (!Fcb->FullFileName.Buffer)
    {
        Fcb->FullFileName.Buffer =
            FsRtlAllocatePoolWithTag(PagedPool,
                                     PathLength,
                                     TAG_FILENAME);
    }

    StopFcb = CurFcb;

    CurFcb = Fcb;
    TmpBuffer =  Fcb->FullFileName.Buffer + PathLength / sizeof(WCHAR);

    /* Set lengths */
    Fcb->FullFileName.Length = PathLength;
    Fcb->FullFileName.MaximumLength = PathLength;

    while (CurFcb != StopFcb)
    {
        /* Get its unicode name */
        FatGetFcbUnicodeName(IrpContext,
                             CurFcb,
                             &LongName);

        /* Copy it */
        TmpBuffer -= LongName.Length / sizeof(WCHAR);
        RtlCopyMemory(TmpBuffer, LongName.Buffer, LongName.Length);

        /* Append with a backslash */
        TmpBuffer -= 1;
        *TmpBuffer = L'\\';

        /* Go to the parent */
        CurFcb = CurFcb->ParentFcb;
    }

    /* Free the temp buffer */
    ExFreePool(LongName.Buffer);
}

Generated on Sun May 27 2012 05:23:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.