Skip to content
This repository

Fix URIUtils::IsDVD function logic #83

wants to merge 2 commits into from

3 participants

Harry Muscle jmarshallnz Ian Firns
Harry Muscle

The logic in the URIUtils::IsDVD function is slightly off, so I've put together this pull request to fix it.

The original logic in that function checked to see if the file name was NOT "X:" or "X:\" (where X could be any letter) and return false if it's not. However, this prevents any of the other checks later in the function from ever being reached. The correct logic should be to check if the file name IS "X:" or "X:\" and if it is return true, otherwise continue running the rest of the function.


Ian Firns

Are you sure your logic is right here?

Firstly, De Morgan would require that && to be a ||. As it stands the latter is always true if the former is.

Secondly, as a 'nix dev, and having not used Windows for some time, would drives such as "C:" be considered a DVD? Your proposal suggests that any valid Windows drive is a DVD. Perhaps look at IsOnDVD and adapt as required.


The new logic will never be met (Mid(1) just drops the first character from the string).

The old logic is "more correct" in that it was designed to detect "D:\" or "D:" and fail on "D:\foo\bar" or "/foo/bar". Ofcourse, that's not ideal under anything non-win32 - and it specifically will fail on dvd:// yet the next check is supposed to handle it.

I suspect the best thing is to drop the first test completely, but someone needs to verify on all platforms.

Sorry guys for the confusion, I forgot to change && to ||. Hopefully with that change my pull will make more sense :)

This pull request has nothing to do with my other patches, I just simply came across this and noticed that it's messed up. As it stands currently, this function under Windows will almost always return false. The section that checks for "dvd://" will never be reached. I simply wanted to bring this to all the devs attention. Feel free to fix it in other ways if you'd like. I simply wanted to put together a patch that makes the least amount of code modifications while still fixing the function.


Harry Muscle

I noticed JMarshall fixed this a day or two ago, so I'll close this pull request.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Mar 27, 2011
Harry Muscle HarryMuscle Fix URIUtils::IsDVD function 464de76
Harry Muscle HarryMuscle Change AND to OR 7998ecc
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 3 additions and 3 deletions. Show diff stats Hide diff stats

  1. +3 3 xbmc/utils/URIUtils.cpp
6 xbmc/utils/URIUtils.cpp
@@ -471,9 +471,9 @@ bool URIUtils::IsHD(const CStdString& strFileName)
471 471 bool URIUtils::IsDVD(const CStdString& strFile)
472 472 {
473 473 #if defined(_WIN32)
474   - if(strFile.Mid(1) != ":\\"
475   - && strFile.Mid(1) != ":")
476   - return false;
  474 + if(strFile.Mid(1) == ":\\"
  475 + || strFile.Mid(1) == ":")
  476 + return true;
477 477
478 478 if((GetDriveType(strFile.c_str()) == DRIVE_CDROM) || strFile.Left(6).Equals("dvd://"))
479 479 return true;

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.